您好,欢迎来到99网。
搜索
您的当前位置:首页javascript如何改变cssText

javascript如何改变cssText

来源:99网

1.改变cssText
例 2.1
<HTML>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
</HEAD>
<BODY>
<SPAN ID="a" STYLE="background-color:RED">ONE</SPAN>
<SPAN ID="b" STYLE="background-color:BLUE">TWO</SPAN>

<FORM>
    <INPUT TYPE="button" VALUE="点 ME" onClick="clickMe()">
</FORM>
<SCRIPT>

    function clickMe()
    {
        var mySp = document.getElementsByTagName("SPAN");
        /*
         style.cssText (Property)
         The CSS style sheet specification source text for this style object.
         Property/method value type: String primitive
         JavaScript syntax: IE myStyle.cssText
         the following statement's result is mySpans[mySpans.length-1].style.cssText="background-color:BLUE"
         */
        mySt1 = mySp[mySp.length-1].style.cssText;
//alert( "mySpans[mySpans.length-1].style.cssText is"+mySpans[mySpans.length-1].style.cssText);
        mySp[0].style.cssText = mySt1;
    }
</SCRIPT>
</BODY>
</HTML>

更多请见:

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- 99spj.com 版权所有 湘ICP备2022005869号-5

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务