jQuery 练习[二]: 获取对象(3) - 根据属性、内容匹配, 还有表单元素匹配
2010-06-11 00:00:00 来源:WEB开发网不符合元素值的, 如: $("span[name!='S2']")
<span id="span1" name="S1">AAA</span><br/>
<span id="span2" name="S2">BBB</span><br/>
<span name="Sx3">CCC</span><br/>
<span name="Sx4">DDD</span><br/>
<div id="div1" name="Dx1">EEE</div>
<div name="D2">FFF</div>
元素值开头是?, 如: $("span[name^='S']")
<span id="span1" name="S1">AAA</span><br/>
<span id="span2" name="S2">BBB</span><br/>
<span name="Sx3">CCC</span><br/>
<span name="Sx4">DDD</span><br/>
<div id="div1" name="Dx1">EEE</div>
<div name="D2">FFF</div>
元素值结尾是?, 如: $("html [name$='1']")
<span id="span1" name="S1">AAA</span><br/>
<span id="span2" name="S2">BBB</span><br/>
<span name="Sx3">CCC</span><br/>
<span name="Sx4">DDD</span><br/>
<div id="div1" name="Dx1">EEE</div>
<div name="D2">FFF</div>
元素值包含?, 如: $("body [name*='x']")
<span id="span1" name="S1">AAA</span><br/>
<span id="span2" name="S2">BBB</span><br/>
<span name="Sx3">CCC</span><br/>
<span name="Sx4">DDD</span><br/>
<div id="div1" name="Dx1">EEE</div>
<div name="D2">FFF</div>
编缉推荐阅读以下文章
- jQuery 练习[二]: 获取对象(2) - 定位子对象
- jQuery 练习[二]: 获取对象(1) - 基本选择与层级
- jQuery 练习[一]: 准备工作
更多精彩
赞助商链接