[JS Master's Road first part] JavaScript on hundreds of actual combat "new" _20 read style with classname and shielded empty anchors

Source: Internet
Author: User

<input type= "button" value= "Restore Style" onclick= "Resetstyle ();"/>

<input type= "button" value= "Modify Style" onclick= "SetStyle ();"/>

1 <!DOCTYPE HTML>2 <HTMLLang= "en">3 <Head>4     <MetaCharSet= "UTF-8">5     <title>Document</title>6     <style>7 Div{8 width:200px;9 Height:200px;Ten background:Red; One         } A . Active{ - width:400px; - Height:400px; the background:Blue; -         } -     </style> -     <Script> +     functionSetStyle () { -         varOBox=document.getElementById ("Box"); + Obox.classname="Active"; A     } at     functionResetstyle () { -         varOBox=document.getElementById ("Box"); - Obox.classname=""; -     } -     </Script> - </Head> in <Body> -     <inputtype= "button"value= "Modify Style"onclick= "SetStyle ();" /> to     <inputtype= "button"value= "Restore Style"onclick= "Resetstyle ();" /> +     <DivID= "box"></Div> - </Body> the </HTML>

1 <!DOCTYPE HTML>2 <HTMLLang= "en">3 <Head>4     <MetaCharSet= "UTF-8">5     <title>Document</title>6     <style>7 Div{8 width:200px;9 Height:200px;Ten background:Red; One         } A     </style> -     <Script> -     functionGetStyle () { the         varOBox=document.getElementById ("Box"); - Console.log (CSS (OBox,'Height')); -     } -  +     functioncss (obj,attr) { -         //compatible with IE8 and Chrome/ff +         if(obj.currentstyle) { A             returnobj.currentstyle[attr]; at         } Else { -             returngetComputedStyle (obj,false) [attr]; -         } -     } -     </Script> - </Head> in <Body> -     <inputtype= "button"value= "read"onclick= "GetStyle ();"> to     <DivID= "box"></Div> + </Body> - </HTML>

[JS Master's Road first part] JavaScript on hundreds of actual combat "new" _20 read style with classname and shielded empty anchors

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.