我有这个,
<td class="optionsImg" style="display:none;">
<img src="../status/approved-01.png" />
<img src="../status/rejected-02.png" />
<img src="../status/pending-01.png" />
</td>
我正在尝试这个,
var allImages = $(".optionsImg").find("img");
现在我需要使用任何可能的技术在上面选择具有“-02.png”的图像,我希望它尽可能短
最佳答案
使用attribute-value ends with selector选择所有 src
属性值以 -02.png
结尾的图像。
$('.optionsImg img[src$="-02.png"]')
如果要选择值中包含字符串 anywhere 的图像,请使用 attribute-value contains selector .
$('.optionsImg img[src*="-02.png"]')
关于javascript - 正则表达式根据文本过滤图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33390043/