What i want to do is stop the clickable link from forwarding the user to the href value as i am calling the value via .load().
Here is my code;
$('#prac_slider li a').click(function(){
var $permalink = $('#prac_slider li a').attr('href');
$('div#abc').load($permalink + ' #loadMe');
});
i have tried to add .unbind('click', variable); to the element and loading my above code via a variable but it still seems to forward the user.
Everything else works, it loads the data into #abc but it then forwards the user to the href itself.
How would i disable this?
Use
return false:This prevents the default action from being performed, in the case of an
ait prevents the link being followed, in the case of a checkbox it prevents un/checking of the box.You could, similarly, use
event.preventDefault():As pointed out by T.J. Crowder, in the comments below,
event.preventDefault()andreturn falseare not equivalent:return falseisevent.preventDefaultandevent.stopPropagation()(the latter of which prevents the event from bubbling up the DOM tree).Reference:
event.preventDefault().event.stopPropagation().