Using `Not` with` Delegate` - JQuery

I currently have something like this:

$(".jtable tbody td").not(".DeleteLicense").hover(

How can I use a delegate with this? Sort of

$("#resultContainer,#approvalContainer,#createNewContainer").delegate(".jtable tbody td....

Thank!

+3
source share
3 answers

You can use the :not()selector to move the negation to your selector.

$("#resultContainer,#approvalContainer,#createNewContainer")
    .delegate(".jtable tbody td:not(.DeleteLicense)", "...", ...);

Note that the jQuery documentation recommends using a function .not()rather than a selector :not()in most cases, but I'm not sure if this is possible in this case.

, , .jtable tbody td delegate, if(!$(this).is(".DeleteLicense")) { ... } , .

+3

:

$("#resultContainer,#approvalContainer,#createNewContainer").delegate(".jtable tbody td:not('.DeleteLicense')", "hover", function(eventObj) {
    // handler code
});
+2

My first thought was to try using a :not()selector :

$("#resultContainer,#approvalContainer,#createNewContainer").delegate(".jtable tbody td:not('.DeleteLicense')", "hover", function(){ /* do stuff */});
0
source

Source: https://habr.com/ru/post/1782470/


All Articles