Home >Web Front-end >JS Tutorial >JQuery uses attr method to implement drop-down list selection_jquery
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>
js code:
<script type="text/javascript"> $('#category option[value=3]').attr('selected',true); </script>