javascript - Placing a div within body tag -
currently have page setup as:
<body id="some-id"> <div class="some-class"> </div> <!-- some-class --> </body> i've tried using append , before, however, it's not quite doing want do.
i'm trying add div id inserted-div this:
<body id="some-id"> <div id="inserted-div"> <div class="some-class"> </div> <!-- some-class --> </div> <!-- inserted div --> </body> each time use something, example: $('body').appendto("<div id='inserted-div'>"); either won't insert or insert </div> after inserted <div> rather placing </div> before closing body. tried prepend , prependto no luck.
you looking wrap method.
$('.some-class').wrap('<div id="inserted-div"></div') $('body').prepend -- add div first child of body.
$('body').append -- add div last child of body.
but in case want inserted-div wrapper existing div.
to target first instance can either use
$('.some-class').first() or $('.some-class:eq(0)')
Comments
Post a Comment