javascript - How can I do jQuery doesn't work for a specific element? -


i have jquery fadeout page smoothly when click on "href" link.

i have ecommerce, have cart can see products have added. (online store: www.backlabel.com)

you can delete cart directly "x" on top of product. "x" have "href" property, page load jquery , bad because whole page re-load.

i wish jquery not work on "x" button. can code in follow jquery?

// delegate clicks on "a" tag (links) $(document).on("click", "a", function (event) {     // href attribute     var newurl = $(this).attr("href");      // veryfy if new url exists or hash     if (!newurl || newurl[0] === "#") {         // set hash         location.hash = newurl;         return;     }      // now, fadeout html (whole page)     $("html").fadeout(function () {         // when animation complete, set new location         location = newurl;     });      // prevent default browser behavior.     return false; }); 

you can exclude href such selection using a:not('#yourid')

$(document).on("click", "a:not('#x')", function (event) {    alert('clicked');  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <a href="#" >link1</a>  <a href="#" >link2</a>  <a href="#" id="x">link3</a>


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -