I would like to run a function on the whole website but not on "a"s. Problem is, that the "a"s are inside "div"s, so selection like
$(':not(a)').myFunction();
does not work (since it is called on the parent-div). Sounds like a simple problem, I just don't seem to find a solution. Thanks!
答案 0 :(得分:3)
$('body > *').not(':has("a")').myFunction();
您可以将not()部分替换为您想要保留的内容。以上内容适用于您的示例。
答案 1 :(得分:0)
答案 2 :(得分:0)
我现在通过解除'a'上的功能来实现它。
$('a').hover(
function () {
$('#tooltip').hide().addClass("hover");
...
和
$("body").on( "click", function() {
....
});
$("a").click(function() {
$("body").off("click");
});