javascript - Open and close floating layer same link? -



javascript - Open and close floating layer same link? -

i have floating layer activates through link:

<a href="javascript:togglefloatinglayer('floatinglayer',1);"> button </a>

this floating layer:

<div id="floatinglayer"> <div id="closex"> <a href="#" onclick="togglefloatinglayer('floatinglayer',0);return false">x</a> </div>

the script:

<script language="javascript1.2"> function togglefloatinglayer(divid, istate) // 1 visible, 0 hidden { if(document.layers) //nn4+ { document.layers[divid].visibility = istate ? "show" : "hide"; } else if(document.getelementbyid) //gecko(nn6) + ie 5+ { var obj = document.getelementbyid(divid); obj.style.visibility = istate ? "visible" : "hidden"; } else if(document.all) // ie 4 { document.all[divid].style.visibility = istate ? "visible" : "hidden"; } } </script>

i want "button" open , close floating layer. opens , closes in same link. right can close through "closex" x. how can it?

jquery standard cross-browser , feature-rich javascript library learning , using jquery in applications best across business apps here links api , leaning sites

http://api.jquery.com/ http://learn.jquery.com/about-jquery/how-jquery-works/

snippet below you

<!doctype html> <html> <head> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script> function togglefloatinglayer(divid) { $("#" + divid).toggle();//its single line manage toggling browsers } </script> </head> <body> <a href="#" onclick="togglefloatinglayer('floatinglayer')"> button </a> <div id="floatinglayer" style="display:none;border:solid 2px silver;"> <div id="closex" style="background:#efefef"> <a href="#" onclick="togglefloatinglayer('floatinglayer')">x</a> </div> <div> test content of floating layer </div> </div> </body> </html>

javascript html css layer floating

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -