Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using `Not` with `Delegate` - Jquery

I currently have something like this:

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

How can I use delegate with this? Something like

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

Thanks!

like image 306
kralco626 Avatar asked Mar 21 '26 05:03

kralco626


1 Answers

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

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

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

If you're willing to use another approach, you may find that you could use the .jtable tbody td selector in your call to delegate, and then use if(!$(this).is(".DeleteLicense")) { ... } in your event handler to only process elements that meet your criteria.

like image 163
Zack The Human Avatar answered Mar 23 '26 18:03

Zack The Human