Home > Web Front-end > JS Tutorial > JQuery uses attr method to implement drop-down list selection_jquery

JQuery uses attr method to implement drop-down list selection_jquery

WBOY
Release: 2016-05-16 16:34:13
Original
906 people have browsed it

The html code is as follows:

<select id="category" name="category">
<option value="">请选择类别</option>
<option value="1">类别1</option>
<option value="2">类别2</option>
<option value="3">类别3</option>
<option value="4">类别4</option>
</select>
Copy after login

js code:

<script type="text/javascript">
$('#category option[value=3]').attr('selected',true);
</script>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template