JS control Show and hide CSS Div code

Source: Internet
Author: User
Keywords Web page production Ajax javascript
Tags ajax block code content control css tutorial display document

This article for your collection of three about JS control display and hide CSS Tutorial div Code Oh, if you are doing show with hidden layer effect, here are jquery and JS control method Oh.

function Showtips Tutorial (tips, height, time) {
var windowwidth = document.documentelement.clientwidth;
var tipsdiv = ' <div class= ' tipsclass ' > ' + tips + ' </div> ';

$ (' body '). Append (Tipsdiv);
$ (' Div.tipsclass '). CSS ({
' Top ': Height + ' px ',
' Left ': (WINDOWWIDTH/2)-(Tips.length * 13/2) + ' px ',
' Position ': ' Differs ',
' Padding ': ' 3px 5px ',
' Background ': ' #8fbc8f ',
' Font ': + ' px ',
' Margin ': ' 0 auto ',
' Text-align ': ' Center ',
' Width ': ' Auto ',
' Color ': ' #fff ',
' Opacity ': ' 0.8 '
). Show ();
settimeout (function () {$ (' Div.tipsclass '). fadeout ();}, (Time * 1000));
}
Method Two

&lt;html&gt;


&lt;head&gt;


&lt;meta http-equiv= "Content-type content=" HTML; charset=gb2312 "/&gt;


&lt;title&gt; Untitled Document &lt;/title&gt;


&lt;mce:script language= "Web Effects" type= "Text/javascript" &gt;&lt;!--


   


function Toggle (targetid) {


if (document.getElementById)


 {   


Target=document.getelementbyid (Targetid);


if (target.style.display== "block")


   {   


target.style.display= "None";


var aaa =document.all ("AA");


var s= ';


for (var i=0;i&lt;aaa.length;i++)


               {   


if (aaa[i].checked==true)


                 {   


S+=aaa[i].value;


                 }   


            }   


else


    {   


target.style.display= "Block";


             }   


     }   


}


//--&gt;&lt;/mce:script&gt;


&lt;mce:style type= "text/css" &gt;&lt;!--


   


#div1 {


height:400px;


width:400px;


Display:none;


}


--&gt;&lt;/mce:style&gt;&lt;style type= "Text/css" mce_bogus= "1" &gt;


#div1 {


height:400px;


width:400px;


Display:none;


}&lt;/style&gt;


&lt;/head&gt;


&lt;body&gt;


&lt;input type= "button" id= "Butn" value= "Show/Hide" onclick= "toggle (' Div1 ')"/&gt;


&lt;center&gt;


&lt;div id= "Div1 style=" Filter:alpha (opacity=100); Position:absolute;  overflow:auto;height:160; top:100px2008-5-26;left:300px;width:100px; "&gt;


Hidden Div


&lt;/div&gt;&lt;/center&gt;


-Centered Div


&lt;/body&gt;


&lt;/html&gt;


Method Three

<!doctype HTML Public-//w3c//dtd XHTML 1.0 transitional//en "<a href=" http://www.w3.org/tr/xhtml1/dtd/ Xhtml1-transitional.dtd "target=" _blank "rel=" external ">http://www.w3.org/tr/xhtml1/dtd/" Xhtml1-transitional.dtd</a> ""
<html xmlns= "<a href=" http://www.w3.org/1999/xhtml "target=" _ Blank "rel=" external ">http://www.w3.org/1999/xhtml</a>"
<head>
<meta http-equiv= " Content-type "content=" HTML; charset=gb2312 "/>
<title>jexm's blog</title>
<script language=" JavaScript type= "text/ JavaScript
<!--
Function Show (Targetid) {
    if (document.getElementById) {
        Target=document.getelementbyid (Targetid);
            if (target.style.display== "block") {
                Target.style.display = None";
    newsinfo.style.height= "1528px"
            } else {
                 target.style.display= "Block";
    newsinfo.style.height= "1583px"
            }
   }

<style
</script>
type= "Text/css"
< !--
#test1 {
Display:none;
}
;
</style>


</head>

<body>
<input name= "niming" type= checkbox "onclick=" Show (' test1 ') "checked > Display or not
<div id= "test1" ><img src= "/logo.gif" border= "0" align= "absmiddle"/></div>
</body>
</html>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.