Prevent default behaviour


/ Published in: JavaScript
Save to your folder(s)

Stop default behaviour from happening.
In the second example we open a jQuery UI dialog instead of going to a different url when clicking on an A-tag with an id of "myLink".


Copy this code and paste it in your HTML
  1. function(evt) {
  2. evt.preventDefault();
  3. };
  4.  
  5. $('#myLink').click(function(evt){
  6. evt.preventDefault();
  7. $('#myLink').dialog('open');
  8. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.