是否有一个选择器,用于当在jQuery('select option [@selected = ....])之类的选择框中选择一个选项时,这很困惑,是否只是jQuery(select> option [@selected]),还有如何在jQuery选择器语句中测试一个不是第一个选项的选项
It would look like this (note there's no @
, this was removed in jQuery 1.3+):
jQuery("select option:selected")
If you wanted to get anything but the first, you can use :not(:first-child)
, like this:
jQuery("select option:selected:not(:first-child)")
//or...
jQuery("select option:gt(0):selected")
Though to get the value, you'd typically just want to call .val()
directly on the <select>
, like this:
jQuery("select").val()
$("select option:selected");
or
$(this, "option:selected");
test not first option
$("select option:not(eq0)"); <---I think
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.