Static pages can also implement different display modes for the preview list [original]_javascript tips

Source: Internet
Author: User
In order to facilitate the viewing of the content, I specifically added a Preview List two list display mode
Written in 2 June-October, reprint please specify the source cloud Habitat Community
Copy Code code as follows:

For list display
function Changeshow (num) {
var Thenum=num,thestyle;
if (num==1) {
Thestyle= "None";
Setcookie ("num", "1", 6)
var elements1=document.getelementsbytagname ("div");
for (Var i=0;i<elements1.length;i++) {
if (elements1[i].id== ' DXY ') {
Elements1[i].classname= ' Info2 ';
}
}
}else
{
Thestyle= ""
Setcookie ("num", "0", 6)
var elements2=document.getelementsbytagname ("div");
for (Var i=0;i<elements2.length;i++) {
if (elements2[i].id== ' DXY ') {
Elements2[i].classname= ' info ';
}
}
}
var elements=document.getelementsbytagname ("div");
for (Var i=0;i<elements.length;i++) {
if (elements[i].id== ' jb51 ') {
if (Elements[i].style.display!=thestyle) {
Elements[i].style.display=thestyle;
}
}
}
}

function Setcookie (name, value)//cookies set JS
{
var argv = setcookie.arguments;
var argc = setCookie.arguments.length;
var expires = (argc > 2)? ARGV[2]: null;
if (expires!=null)
{
var largeexpdate = new Date ();
Largeexpdate.settime (Largeexpdate.gettime () + (expires*1000*3600*24));
}
Document.cookie = name + "=" + Escape (value) + ((expires = null)? "" : ("; Expires= "+largeexpdate.togmtstring ()));
}

function GetCookie (Name)//cookies Read JS
{
var search = Name + "="
if (Document.cookie.length > 0)
{
offset = document.cookie.indexOf (search)
if (offset!=-1)
{
Offset + = Search.length
End = Document.cookie.indexOf (";", offset)
if (end = = 1) end = Document.cookie.length
return unescape (offset, end) (document.cookie.substring)
}
else return ""
}
}


Ps:
1, you generate static file to have <div id=jb51> words, of course, you can change the attention of the random
In the preceding code var elements=document.getelementsbytagname ("div");
Code
2. Calling method:
Copy Code code as follows:

<script type=text/javascript language=javascript src= "List.js" ></script>

3. Attached Poplist.js
Copy Code code as follows:

try{
var dxynum=getcookie ("num");
Changeshow (Dxynum);
}
catch (e) {

}

Specific application: http://www.jb51.net/html/list/list_1_1.htm

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.