javascript - Adding div before selected div -
i have bunch of divs 1 after other.
<div class="betweenable">some content</div> <div class="betweenable">other content</div> <div class="betweenable">yet another</div>
when click last div, want insert text new content
in div before it, final result be
<div class="betweenable">some content</div> <div class="betweenable">other content</div> <div class="betweenable">new content</div> <div class="betweenable">yet another</div>
i tried append
it's adding new markup inside select div at top. want inserted outside selected div , right before it. should use instead of line
var newmarkup = '<div class="betweenable">new content</div>'; $(this).prepend();
you can try
$('.betweenable').click(function(){ var newmarkup = '<div class="betweenable">new content</div>'; $(this).before(newmarkup); });
here's example : http://jsfiddle.net/jomanlk/c4xyh/
Comments
Post a Comment