Reputation: 3255
I have a simple example for testing:
<input id="test" type="text">
<input id="ts" type="submit">
I want to use jQuery to alert when the submit button with the id "ts" is pressed.
$('#ts').on("click", function() {
alert(1)
});
But nothing is happening. Where when I do the exact same thing in the Javascript console of chrome, everything works fine.
Upvotes: 0
Views: 173
Reputation: 6839
You should put this at the load event of the document as above:
$(document).ready(function(){
$('#ts').on("click", function() {
alert(1)
});
});
Upvotes: 1