Home > Web Front-end > JS Tutorial > jQuery operation drop-down list box implementation code_jquery

jQuery operation drop-down list box implementation code_jquery

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 18:34:08
Original
959 people have browsed it


1. Get the jQuery object
obj = $('#select1');

2. Get the length of Options
len = $('#select1 option').length

3. Traverse options
for (var i = 0; i option_value = obj[0].options[i].value;
option_text = obj [0].options[i].text;
}

4. Get the selected value
obj_value = $('#select1').val();

5. Get the text corresponding to the selected value
obj_text = obj[0].options[obj[0].selectedIndex].text;

6. Add an option
obj.append(' ');

7. Delete an option
$('#select1 option[value="1"]').remove();
Related labels:
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
Latest Issues
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template