javascript - jquery .addClass to future js generated html -


i this:

$(".field-validation-error").addclass('ui-state-error'); 

and @ moment happens

$("body").prepend("<span class="field-validation-error">this field required.</span>") 

i new added element have class 'ui-state-error'

you can either add yourself, changing .prepend() call, or use the .livequery() plugin, this:

$(".field-validation-error").livequery(function() {   $(this).addclass('ui-state-error'); }); 

this execute bounds .field-validation-error elements, , future ones. or, if changing stylesheet option, include both selectors:

.field-validation-error, .ui-state-error { ....styles.... } 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -