I have a simple JQUERY script that I have in the document head.
$(window).on('load', function() {
$(".quick-book-pc").prepend("<p>prepended paragraph</p>")
});
It supposed to locate the first DIV with the class .quick-book-pc and add the paragraph and inner text, When the window loads there are no errors but the paragraph is not added.
If I run the script in the console it adds the paragraph fine.
What am I missing?
2
Answers
Here is an example for your reference:
Seems your DIV.quick-book-pc is added after the page load. Use MutationObserver to detect that: