How to Avoid Page Refreshing on Anchor Tag Click using JavaScript

How to Avoid Page Refreshing on Anchor Tag Click

Some time page load automatically many time when we execute it manually we can prevent it using event handler

  • Event handler prevent auto load of page using prevent Default method [preventDefault()]
  • Generally page loaded automatically after execute it manually and some time it loaded time of event perform like onclick,onkeypress, onchnage etc.
  • prevent default in ready function.


$(document).ready(function(event){

event.preventDefault();

});

  • prevent default in onclickfunction.

<a href="https://programmingconcept.com">programmingconcept.com</a>;

$(document).ready(function(){

$("a").onclick(function(event){

event.preventDefault();
});
});

17 Replies to “How to Avoid Page Refreshing on Anchor Tag Click using JavaScript”

  1. Needed to create you this little remark to thank you once again over the stunning pointers you’ve shown on this site. This is extremely open-handed of people like you to give easily what many individuals might have sold for an e-book to make some cash for themselves, principally seeing that you could have done it if you ever wanted. Those tips in addition served as a great way to realize that some people have the identical interest like my very own to find out a lot more on the topic of this problem. I’m sure there are numerous more fun moments in the future for individuals who read through your blog post.

  2. I truly wanted to write a note in order to thank you for these unique advice you are showing at this site. My long internet investigation has now been honored with excellent tips to talk about with my close friends. I ‘d suppose that many of us site visitors actually are quite lucky to live in a wonderful site with very many brilliant people with useful opinions. I feel extremely blessed to have discovered your website and look forward to really more brilliant moments reading here. Thanks a lot once more for everything.

  3. I simply wished to say thanks yet again. I am not sure the things that I might have sorted out without the actual recommendations shared by you regarding my area. Entirely was a real traumatic setting in my opinion, however , understanding a new professional technique you solved that forced me to jump for joy. I am happier for the guidance and thus expect you recognize what a powerful job that you’re undertaking training people all through your web page. Most likely you’ve never encountered any of us.

  4. Thank you for the good writeup. It in fact was a amusement account it.

    Look advanced to far added agreeable from you!
    By the way, how can we communicate?

  5. I really like your blog.. very nice colors & theme. Did you create this
    website yourself or did you hire someone to do it for you?
    Plz answer back as I’m looking to construct my own blog and would like
    to find out where u got this from. thank you

  6. I just want to mention I am newbie to blogs and definitely savored this website. Almost certainly I’m want to bookmark your blog post . You really have outstanding posts. Bless you for revealing your web page.

Leave a Reply

Your email address will not be published. Required fields are marked *