Prevent click on anchor tag href hash

0.75K views
no comments
7 Sep 2014 10:29 am

In html on anchor tag without a href link we had # into href but when we click on that href with # hash its moved scroll to top position of page and add # in end of the page url, and we feeling annoyed on click that link, here is the simple code to prevent # link in #jQuery

jQuery("body").delegate("a","click",function (eve) {
   var href_val = j(this).attr("href");
   if(href_val == "#"){
       eve.preventDefault();
   }
})

NOTE:Your Email Address will be not shown and please do not add spamming comments because here is REL="NOFOLLOW" on your links and comments also moderated shown.
<code>Put html css or any language code under this tag</code>