In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of "jQuery how to obtain the value of the select drop-down box". The editor shows you the operation process through an actual case. The operation method is simple and fast, and it is practical. I hope that this article "how to obtain the value of the select drop-down box by jQuery" can help you solve the problem.
Several scenarios for getting the select drop-down box are as follows:
1. Get the value of the first option
('# test option:first'). Val ()
two。 Value of the last option
('# test option:last'). Val ()
3. Get the value of the second option
('# test option:eq (1)'). Val ()
The values of the third and fourth option can be obtained by analogy
4. Get the selected value
Var groupid = $("# groupid"). Find ("option:checked"). Val (); $('# groupidoption:selected'). Val (); $('# groupid'). Val ()
5. Set option to be selected with a value of 2
$('# test'). Attr ('value','2')
6. Set the last option to be selected
$('# test option:last'). Attr ('selected','selected'); $("# test"). Attr (' value', $('# test option:last'). Val ()); $("# test"). Attr ('value', $(' # test option'). Eq ($('# test option'). Length-1). Val ())
7. Get the length of the select
$('# test option') .length
8. Add an option
Var str= "item N + 1"; $("# test") .append (str); / / this is generally used to append $("item N + 1") .appendTo ("# test")
9. Delete selected item
('# test option:selected'). Remove ()
10. Delete the first item in the selection
('# test option:first'). Remove ()
11. Delete an option that meets the criteria
$('# test option') .each (function () {if ($(this). Val () ='5') {$(this). Remove ();}}); $('# test option [value=5]'). Remove (); this is the end of the content about "how jQuery gets the value of the select drop-down box". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.