javascript - jQuery hide appended div items -
i have following code , trying hide/show inner/appended items, such text1, text2 , text3:
html:
<div id="div1"> <a href="#" id="clickitem">link</a> <br /> text1 <br /> text2 <br /> text3 </div>
jquery:
var hide = false; $("#clickitem").click(function (e) { if (hide == false) { $("#div1").hide(); hide = true; return; } else { $("#div1").show(); hide = false; return; } });
you can wrap inner text in div , toggle inner div onclick of link. please check below snippet more idea.
var hide = false; $("#clickitem").click(function (e) { $("#innerpart").toggle(); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="div1"> <a href="#" id="clickitem">link</a> <div id="innerpart"> <br /> text1 <br /> text2 <br /> text3 </div> </div>
Comments
Post a Comment