html - Replacing innerhtml for a specific div that shares the same id as other divs? -
so i've done quite bit of research , still haven't got work. trying replace innerhtml of div. have got work following code:
<script type="text/javascript"> var embedcode = 'new html goes here'; </script> <div id="videocontainer"> <img class="playbutton" onclick="document.getelementbyid(videocontainer).innerhtml = embedcode;return false;" src=""/> </div>
this post template copy , paste , change images/embedcode. works if have 1 post. once add post, both not work since both sharing same embedcod name , same div id. there solution around without using jquery?
i've tried using
document.getelementbyid(this.id).innerhtml = embedcode
instead of
document.getelementbyid(videocontainer).innerhtml = embedcode
but still not working. thanks.
id
supposed unique. increment counter or use post id part of id
attribute.
for ease of styling, add class them well, e.g. <div class="videocontainer" id="videocontainer1">
. use class styling , id js.
Comments
Post a Comment