jquery - on() doesn't work as expected and does not work for newly loaded content -


my chrome extension follows:

$(document).ready(function() {     ...     $("input[type!='password'], textarea").on("keypress", function (event) {         ...     }); }); 

this reacts expected loaded content not work inputs or textareas loaded later.

i though on supposed do, using wrong?

i've played around try solve no success

$(doocument).on("keypress", "input[type!='password'], textarea".... 

here live example in jsfiddle, first input works expected, generated ones don't.

$(document).on("keypress", "input[type!='password'], textarea", function (event) {     alert("this works!"); }); 

the listener being attached document, , keypress events checked against input[type!='password'] , textarea.

if html markup structured in way there 1 parent container of input[type!='password'] , textarea, replace $(document) $('.parent-container') attach listener on element, opposed entire document.

edit: here's example: http://jsfiddle.net/yz7f5/5/


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -