spy*_*der 4 html jquery html5 class
使用jQuery 1.9.1和HTML5,我想捕获只有特定类名的元素.
假设我有以下HTML代码:
<div>
<span class="req">A</span>
<span class="req notreq">B</span>
<span class="req notreq">C</span>
<span class="req">D</span>
</div>
Run Code Online (Sandbox Code Playgroud)
我想只捕获<span>具有类的元素,req即值A和D.
使用jQuery,我可以使用console.log($('.req'));所有notreq值和所有值来捕获console.log($('span.req.notreq'))
我只需要req价值观.有帮助吗?
只需将类名添加到选择器中,就像这样......
$("span[class='req']");
Run Code Online (Sandbox Code Playgroud)
这只会将span元素req作为一个类返回.
| 归档时间: |
|
| 查看次数: |
12411 次 |
| 最近记录: |