javascript alert firing on document ready even though it's in click event -
i've got simple question, code below keeps firing alert when page loads, alert in click event don't know why. ideas?
<script> $(document).ready( function () { var blah = document.getelementbyid('btnchangescreensize'); var blah2 = $('#btnchangescreensize'); $('#btnchangescreensize').click(alert(1)); } ); </script>
thanks,
write this:
$(document).ready( function () { var blah = document.getelementbyid('btnchangescreensize'); var blah2 = $('#btnchangescreensize'); $('#btnchangescreensize').click(function() { alert(1) }); } );
the thing is, when write: $('#btnchangescreensize').click(alert(1))
function alert()
being called , returns undefined
. you're setting undefined
callback function, doesn't make sense
Comments
Post a Comment