Sunday, November 4, 2012

alternative to href="#" : to prevent href="#" link from jumping to top of page: function() { ...everything... return false; }

1
alternative to href="#" : to prevent href="#" link from jumping to top of page: function() { ...everything... return false; }

alternative to href="#"

Regarding "sending the user to the top of the page"; you should just return false from your the function you have hooked up as a click() handler;
$('a').click(function() {
    // Do your stuff.
    // The below line prevents the 'href' on the anchor to be followed.
    return false;
});




2
jquery getting the text of an element
http://api.jquery.com/text/



3


Simulating a click in jQuery/JavaScript on a link



$( 'selector for your link' ).click ();

http://stackoverflow.com/questions/1839363/simulating-a-click-in-jquery-javascript-on-a-link
http://api.jquery.com/click/




4

jquery prevent default on anchor

jQuery anchor preventDefault


http://stackoverflow.com/questions/3786898/jquery-anchor-preventdefault

jQuery('#demoLink').bind('click',function(e){
      e.preventDefault();
      document.location.href="someUrl.php?text="+ jQuery('#demoQuery').val();     
});




No comments:

Post a Comment