Having a hard time figuring out why this alert code is being called once on 1st click, twice on 2nd click, four times on 3rd click, eight times on 4th click, etc…
$(document).ready(function() {
$('#preventClickDiv a[href]').click(function(e){
e.preventDefault();
alert('Prevented');
newClick();
});
});
function newClick(){
$('#preventClickDiv a[href]').click(function(e){
e.preventDefault();
alert('Prevented');
newClick();
});
}
The first block creates a click event that calls
newClickwhich creates a click event that calls itself… which creates another event… I think you get the idea. Take out the click event binding code in the function.It should just be something like: