how can i hide or show a links through javascript? can u help me with code of javascript? which method to call for it?
you can make it <script> function show(obj) { obj = document.getElementById(obj).style; obj.display='block'; } function hide(obj) { obj = document.getElementById(obj).style; obj.display='none'; } </script> <div onmouseover="show('adiv')" onmouseout="hide('adiv')">Put Your Mouse Here</div> <div id="adiv" style="display:none;"> Some text </div>
wrapper it up function toggle(id) { var el = document.getElementById(id); if ( el.style.display != 'none' ) { el.style.display = 'none'; } else { el.style.display = 'block'; } }
Better use jQuery (a JavaScript framework). To show/hide links with this HTML structure.. <div id="main"> <a href="#">Hyperlink</a> </div> Code (markup): the jQuery code will be.. $(' div#main a ').hide(); // for hiding links by default $(' div#main ').hover(function() { $(this).child("a").show(); // shows links on mouseIn }, function() { $(this).child("a").hide(); // hides links on mouseOut }); Code (markup): for more information on jQuery check - jQuery.com enjoy
yeah j query is better for this. alternatively, the link can be put inside the div and toggle the div status on click or on focus will get the same effect. i hope the issue is already solved....