javascript - Make a child div visible on click -
edit code make work please.
edited latest version.
here have:
<body> <!-- visibility toggle --> <script type="text/javascript"> <!-- function toggle_visibility() { if(document.getelementbyid(window.event.srcelement.id+'menu').style.display=='block'){ document.getelementbyid(window.event.srcelement.id+'menu').style.display='none'; } else{ document.getelementbyid(window.event.srcelement.id+'menu').style.display='block'; } }; //--> </script>
here divs (edited show have)
<ul class="lyrics"><h3>all lyrics</h3> <?php while ( have_posts() ) : the_post(); ?> <li ><a id="links" href="#" onclick="toggle_visibility();"><?php the_title(); ?></a> <div id="linksmenu"><?php the_content();?></div> </li> <?php endwhile; // end loop. whew. ?> </ul>
here happens: regardless link click on, text associated last "the_content" displays.
here need: "child" divs not visible. when click on "title 1" link, "child text 1" become visible. when click on "title 2" link, "child text 2" become visible , "child text 1" become not visible.
this going in wordpress blog number of title divs change. there 1 child.
thanks in advance!
the reason why first div
toggled no matter click, because use hard-coded id foo
. pass this
toggle_visibility
instead of literal 'foo'
, inside toggle_visibility
function find div want toggle (this going first child of passed parameter).
Comments
Post a Comment