Reputation: 51
I have jQuery .click(function() event handlers attached to elements that I've selected by ID
example:
$('#deletethis').click(function() {
$(this).hide()
}
within my $(document).ready but this does not work at all with Safari, just nothing happens but it works fine with Chrome, Firefox, and IE. Console reports no javascript errors. Nothing inside the .click handler gets executed at all. Is there a work around for safari to accomplish the same effect?
Upvotes: 2
Views: 6312
Reputation: 51
Nevermind, found out it was an issue with only Safari not loading the javascript file, but all other browsers are. Got to figure that out now. . .
Upvotes: 3
Reputation: 25946
Is #deletethis a link? Possibly with href="". If so, the default action on it is to navigate to the url of the page.
You can prevent the default action by calling e.preventDefault() in the click handler.
$('#deletethis').click(function(e) {
e.preventDefault();
$(this).hide();
});
Upvotes: 0
Reputation: 12532
Put a semicolon after hide().
End the click function with a ');' after the function.
Upvotes: 0
Reputation: 669
Have you tried this?
$('#deletethis').click(function() { $(this).hide(); });
Note the extra ; and );
Upvotes: 1