Question

I want to write a user script that runs some custom JavaScript code on each <input type="password"> field that gets loaded. I could register an event handler on document load to look for all input fields and run the JavaScript code on them, but that means firstly that the JavaScript code won't run on input fields that subsequently get added by other JavaScript code, and secondly it won't run until the page is fully loaded.

I want to put ChromaHash into all of my password fields.

Was it helpful?

Solution

The jQuery livequery library could do this for you. It would look like this:

$('input').livequery(function() {
  doSomethingToTheInput(this); //this == the input
});

OTHER TIPS

The featuers of the livequery plugin where integrated into the latest jQuery you can now use them by calling live().

Example:

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top