Day5------------Functioncss

Source: Internet
Author: User

Style can only get the inline style, if you need to get the current property value of the element you want,

Ie:

You can use object. Currentstyle.width;

Ff:

You can use getComputedStyle (object,false). width;

A function CSS has been created to control the style that provides UI interaction and completes the parameter matching

1<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">234<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>5<title>functionCss</title>67<style type= "Text/css" >8div{width:700px;height:400px;background:gray;font-Size:20px;cursor:pointer;}9</style>Ten<script type= "Text/javascript" > OneWindow.onload=function(){ AOdiv=document.getelementsbytagname (' div ') [0]; -Obtn=document.getelementsbytagname (' Input '); -Odiv.innerhtml= "If you don t init the value,you get the current value.<br/>or else,you change it.<br/>re:<b R/>textbox1:width,height,backgroundcolor,fontsize<br/>textbox2:**px,pink,red, #CCC "; the         functionCss (obj,attr,value) { -             if(odiv.currentstyle) { -                 if(arguments.length==2) alert (obj.currentstyle[attr]); -                 Elseobj.style[attr]=Value;  +             } -             Else if(getComputedStyle) { +                 if(arguments.length==2) alert (getComputedStyle (OBJ,false) [Attr]); A                 Elseobj.style[attr]=Value;  at             } -         } -obtn[2].onclick=function(){ -             if(obtn[0].value) { -                 if(Obtn[1].value) CSS (odiv,obtn[0].value,obtn[1].value); -                 ElseCSS (odiv,obtn[0].value); in             }             -         } to     } +</script> -<body> the<div></div> *<input type= "text" placeholder= "the attribute to get"/> $<input type= "text" placeholder= "The value to change"/>Panax Notoginseng<input type= "button" value= "Submit" > -</body> the

Day5------------Functioncss

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.