JQuery Hyperlink Click

JQuery Hyperlink Click

JQuery Hyperlink click

Here we will see how to attach click event to hyperlink html element. We can also stop default behavior of hyperlink onClick.

$("a").click( function(e) {    
                                    
            e.preventDefault();
     
           });   

Above code attaches click event to all hyperlinks present on page. Function preventDefault() stops the default behavior.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

<script type="text/javascript" language="javascript">

    $(document).ready(function(){

    
        $("a").click( function(e) {    
                                 
         e.preventDefault();
  
        });   
      
    });

</script>
HTML Source.
<div>
           <a href="http://www.satalaj.com">www. satalaj .com</a>
           <a href="http://www.jquery.com"> www. jquery .com </a>
           <a href="http://revenmerchantservices.com"> reven merchant services .com</a>
       </div>

Where to go from here?

Learn how to track user activities on page.

Track user activities on page.

Tags:

How To Hide Div On Click Using JQueryBasics of jqueryJQuery SlideLearning JqueryJQuery Change Div background Color and Text Color On ClickJQuery On Click Change Div ContentJquery Mouse Click PositionJquery image click eventJquery button click eventJquery Trim StringJQuery Animate Div Height and Width

Author

My name is Satalaj, but people call me Sat. Here is my homepage: . I live in Pune, PN and work as a Software Engineer. I'm former MVP in ASP.net year 2010.
Disclaimer: Views or opinion expressed here are my personal research and it has nothing to do with my employer. You are free to use the code, ideas/hints in your projects. However, you should not copy and paste my original content to other web sites. Feel free to copy or extend the code.
If you want to fight with me, this website is not for you.
 

I'm Satalaj.