How can I write a script that will change an input field's text value, but the field is not yet created?
The script is loaded before the input field is created. It needs to know that when any input with a certain class is created, it will then have some text put in to its value. Can this be done with live()
?
To clarify, the order of events are:
1 - Application-wide JavaScript for the page is loaded. This contains script something along the lines of:
$('.myDiv input').each(function() {
$(this).val('some text');
});
2 - A second page-specific script is now loaded, which dynamically creates an input on the page, with no value. I CANNOT MODIFY THIS SCRIPT. This is important, I need a solution that does not modify this script (otherwise I wouldn't be posting here).
$('.myDiv').html('<input type="text" />');