live()
(which is now deprecated, so use on()
instead) for events. Unable to select an item that does not yet exist. However, you can create an element like this:
var previewDiv = $('<div id="#preview" />');
And this div is not yet attached to your document. You can manipulate your CSS as you like:
previewDiv.css({ 'background-color': good_color });
Then your script, which was previously responsible for creating the script, can simply attach it:
previewDiv.appendTo(parentElement);
Nathan macinnes
source share