Ale*_*lex 2 html javascript jquery jquery-selectors
如何选择以".jpg",".gif","png"结尾的链接,但只能选择某个DIV内的链接?
喜欢
<div class="stuff_to_select">
<a href="foo.jpg"> ... </a>
<a href="boo.jpg"> ... </a>
</div>
<div class="stuff_to_ignore">
<a href="moo.jpg"> ... </a>
<a href="boo.jpg"> ... </a>
</div>
Run Code Online (Sandbox Code Playgroud)
实际上我认为使用选择器的属性结束会更合适
http://api.jquery.com/attribute-ends-with-selector/
下面的示例将找到位于div下的所有jpg,gif和png href标记,其类名为"stuff_to_select"
$("div.stuff_to_select a[href$='jpg'],
div.stuff_to_select a[href$='gif'],
div.stuff_to_select a[href$='png'],")
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
597 次 |
| 最近记录: |