I am using this function on a wordpress site to move an html element after another html element.
jQuery(document).ready(function($) {
$(".promoted-products-box").insertAfter(".top-rated-prod-position");
})
This function works fine, however i noticed when refreshing the page, it only works about 60% of the time.
I assume this issue is because the widget content ".promoted-products-box" has not fully loaded in yet. And sometimes the jQuery will run before this element is loaded on the page? That is what i am assuming.
So i was wondering if i could run the above script only once the ".promoted-products-box" element has been loaded on the page successfully. How would i do something like that?
Thanks for any help!