用于链接的jQuery选择器,里面没有图像 [英] jQuery selector for link without an image inside
本文介绍了用于链接的jQuery选择器,里面没有图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将一个点击
函数绑定到一个链接:
I bind a click
function to a link:
$("body").on("click", "a", function() {
//do something
});
现在我正在寻找一个只有在链接不包含图片标签时才会匹配的选择器。有点类似于 a:not(img)
但是 img
是子元素。
Now I am looking for a selector that will only match if the link does not contain an image tag. So kind of similar to a:not(img)
but img
being the child element.
我该怎么做?
推荐答案
试试这个:
$("body").on("click", "a:not(a:has(img))", function() {
//do whatever you want here
});
这篇关于用于链接的jQuery选择器,里面没有图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文