javascript - On Text-Click Show (Function) -


i need little here , please excuse me newbie programming.

i have code javascript

function toggle_visibility(id) {        var e = document.getelementbyid(id);        if(e.style.display == 'block')           e.style.display = 'none';        else           e.style.display = 'block'; } 

and how inherit on html

<a href="#" onclick="toggle_visibility('something');"><center>show something</center></a>  <div id="something" style="display:none;"> <p>something</p> </div> 

what when clicks on "show something" , text in div showed up. have 2 problems , hope guide me.

the place on site placed not in beginning , when clicked href="#" takes viewer scrolled on beginning of site.

note want text-click. not button.

second , optional : add jquery on below code has little animation on click-showing?

while frowned upon can change anchor tag following avoid anchor link going top of page:

<a href="javascript:;" onclick="toggle_visibility('something');"><center>show something</center></a>

the ideal scenario not use anchor tag if aren't linking something.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -