Reputation: 46222
I have the following:
<input type="submit" id="submit" value="Submit" />
Inside of jQuery I have have the following:
<script type="text/javascript">
$(document).ready(function () {
$("#submit").on("click", function () {
alert('test');
});
});
</script>
This doesn't work. I am using IE9.
Might anybody know which version of Jquery is supporting .on()
?
Upvotes: 6
Views: 8183
Reputation: 738
I encountered this using when using IE9 in compatibility mode. Note, I had no problem when using IE9 in regular mode.
I was able to do a more thorough QA for a site I just launched (time didn't permit much cross-browser testing beyond using a screenshot service). Changing $("something").on("click"...) to $("something").click() fixed the issue.
Upvotes: 0
Reputation: 81
Make sure that the 'submit' element you are referring to actually exists at document load. If you are creating it dynamically, the 'on' function will have nothing to bind it to.
Upvotes: 0
Reputation: 1383
IE doesn't do well when using 'reserved' names as element's ID.
See this fiddle, your code works great if you change the ID of the input to something different than '#submit'
Upvotes: 1
Reputation: 430
Try following alternates:
$('#submit').bind('click', function() {
alert('Test');
});
OR
$("#submit").click(function(){
alert("Test");
});
Upvotes: 1
Reputation: 218732
Use this version of on
$(function(){
$(document).on("click","#submit", function (e) {
//e.preventDefault(); // if you want to prevent default form submission
alert('test');
});
});
Upvotes: 6
Reputation: 15338
make sure you load jQuery.js
then try:
$("#submit").click(function(){
alert("test");
})
Upvotes: 2