Home > Back-end >  Jquery click link to .show loader unless link has class
Jquery click link to .show loader unless link has class

Time:12-04

I have a jquery function that .show() my "loading screen" by adding .loader class that wraps the entire body when I click on any links. But there are some links I don't want to show the .loader class. If I add a class to some of the a tags like no-load, can I use jquery's hasClass to not run the .loader function? Does anyone know how to do it?

Here's my code that works for all my links:

$(function () {
$('ul.menu a, .logo-img a').click(function () {
  $('.loader').show();
  });
});

CodePudding user response:

You can try using .not() like:

$('ul.menu a, .logo-img a').not('.no-load').click(function () {
  • Related