jQuery ON error. No error when using LIVE -


this question has answer here:

this current, want change .live .on not working..

$('#searchstring').live('keydown',function(e) { if (e.which == 13) {     if (!$("#searchstring").val()) {         alert("inget postnummer eller ort angiven!");         return false;     } } });      $('#searchstring').on('keydown',function(e) { if (e.which == 13) {     if (!$("#searchstring").val()) {         alert("inget postnummer eller ort angiven!");         return false;     } } }); 

this on version

in event delegation model of on() target element selector passed second argument on() method.

$(document).on('keydown', '#searchstring', function(e){     if (e.which == 13) {         if (!$("#searchstring").val()) {             alert("inget postnummer eller ort angiven!");             return false;         }     } }) 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -