[英]jQuery selector statement selecting a select box option tag
是否有一个选择器,用于当在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 1.3+中已删除):
jQuery("select option:selected")
If you wanted to get anything but the first, you can use :not(:first-child)
, like this: 如果您想获得除第一个以外的任何东西,可以使用
:not(:first-child)
,如下所示:
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: 虽然要获取值,但通常只想直接在
<select>
上调用.val()
,如下所示:
jQuery("select").val()
$("select option:selected");
or 要么
$(this, "option:selected");
test not first option 测试不是第一选择
$("select option:not(eq0)"); <---I think
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.