javascript - input .on('keydown') not working at first time -
i want use .on() listening event of input text in jquery , code, it's not working on keydown in first time pressed key:
$(s.join(", ")).on('keyup paste change focus blur keydown', function(e) { if($(e.target).val()!='') console.log(e.which); })
the keydown event gets fired, character isn't added yet. checking if value empty won't do. should try this:
$(s.join(", ")).on('keyup paste change focus blur keydown', function(e) { if($(e.target).val()!='' || e.type == 'keydown') console.log(e.which); }) for demonstration of values @ keydown , keyup, check http://jsfiddle.net/vtude/ (look in console log)
Comments
Post a Comment