I need to add some html right after the body tag so like :
<body>
<p>this is the HTML I need to add</p>
</body>
Here is my jQuery code :
jQuery(document).ready(addPageFlipHTML);
function addPageFlipHTML() {
jQuery('body') // after body tag
.after(
"<div id='pageflip'><a href='http://sabwd.com'><img src='/test/wp-content/plugins/page-flip/images/page_flip.png' alt='' />" //create this html
+ "<span class='msg_block'>Subscribe via RSS</span></a></div>");
}
Does anyone know how to do this? I am trying to write a universal plugin and need a definite tag like body to add after but inside.
Thanks in Advance,
Mike
To position new content inside the opening
<body>element, you want theprepend()(docs) method instead:The reason is that
jQuery('body')doesn’t select the opening<body>tag, but rather the entire<body></body>element.So the
after()(docs) method was attempting to place the new content after</body>, which is invalid. But.prepend()places new content inside thebody(and before any other content that may be inside).