jquery - How to manipulate DOM after new elements have been inserted? -


i working on woocommerce/wordpress site @ moment , on checkout page, when submit form, submits through ajax , if there errors (required fields not filled in etc), page inserts html , lists fields need filled in.

i have jquery places newly inserted html in page new place on page doesn't work.

woocommerce code inserted on submit (if errors):

<ul class="woocommerce-error">     <li><strong>first name</strong> required field.</li> </ul> 

my code:

var wc_errors = jquery('ul.woocommerce-error'); jquery('.errors_placeholder').append(wc_errors); 

it might useful note javascrript file loaded before woocommerce javascript file.

thanks guys

try following:

$(document).ready(function() {     var wc_errors = $('ul.woocommerce-error');     $('.errors_placeholder').appendto(wc_errors);     }); 

you need in $(document).ready function tell jquery dom ready.

check out example


Comments

Post a Comment

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -