JQuery is not activated when changing

I have a problem with a very simple function that is trying to generate when a text field changes. This seems to be a frequently asked question, but most of the time, it seems, revolves around the top $ (document). Not enough already.

however it pounds me. I have a few other jQuery elements firing correctly, but this one doesn't seem to want it. Any ideas guys?

detection: <input type="text" placeholder="detect value" name="txt_detection" id="txt_detection">
$(document).ready(function() {
  $('#txt_detection').on('change, keyup', function(){
    alert "oops!";
  });
});

I have a fiddle too: https://jsfiddle.net/hzmjjzd9/

Any help gratefully received.

+4
source share
2 answers

. -, on() , , . -, , alert(). :

$(document).ready(function() {
    $('#txt_detection').on('change keyup', function() {
        alert("oops!");
    });
});

+4

, ,
jsfiddle jquery, .

$(document).ready(function() {
  $('#txt_detection').on('input', function() {
    alert("oops!");
  });
});

jsfiddle.

, .

0

Source: https://habr.com/ru/post/1670933/


All Articles