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
Post a Comment