亚洲最大看欧美片,亚洲图揄拍自拍另类图片,欧美精品v国产精品v呦,日本在线精品视频免费

  • 站長資訊網(wǎng)
    最全最豐富的資訊網(wǎng)站

    js怎么設(shè)置元素css樣式

    設(shè)置方法:1、使用“對(duì)象.setAttribute('style', '屬性:值')”語句;2、使用“對(duì)象.style.setProperty('屬性', '值')”語句;3、使用“對(duì)象.style.cssText='屬性:值'”語句。

    js怎么設(shè)置元素css樣式

    本教程操作環(huán)境:windows7系統(tǒng)、javascript1.8.5版、Dell G3電腦。

    方法1:使用setAttribute()

    <p id="p">hello world<p>  <button onclick="myFunction()">點(diǎn)擊按鈕,設(shè)置css樣式</button>  <script> function myFunction() { 	document.getElementById("p").setAttribute('style', 'color:#FF0000'); } </script>

    效果圖:

    js怎么設(shè)置元素css樣式

    方法2:使用setProperty()

    <p id="p">hello world<p>  <button onclick="myFunction()">點(diǎn)擊按鈕,設(shè)置css樣式</button>  <script> function myFunction() { 	document.getElementById("p").style.setProperty('font-size', '50px'); } </script>

    效果圖:

    js怎么設(shè)置元素css樣式

    方法3:cssText屬性

    <p id="p">hello world<p>  <button onclick="myFunction()">點(diǎn)擊按鈕,設(shè)置css樣式</button>  <script> function myFunction() { 	document.getElementById("p").style.cssText='font-size:50px;color: red;'; } </script>

    效果圖:

    js怎么設(shè)置元素css樣式

    【推薦學(xué)習(xí):javascript高級(jí)教程】

    贊(0)
    分享到: 更多 (0)
    網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)