html - Changing innerHTML in javascript removes link -
i have block of text want keep hidden until user asks view it. html:
<a href="javascript:toggledisplay('01');"> <div id="title01"> show details </div> </a> <div id="hide01" class="details"> description: </div>
now, block hiding , showing works fine, when change innerhtml on div title01
, no longer remains link.
here's js:
var div = document.getelementbyid('hide'+div_id); var title = document.getelementbyid('title'+div_id); if (div.style.display === 'block') { div.style.display = 'none'; } else { div.style.display = 'block'; title.innerhtml = 'hide'; }
since changing innerhtml
on div id title01
only, fail understand why doesn't remain link. , can fix that?
use jquery text function change content
$('#title01').text("data display");
Comments
Post a Comment