午夜国产狂喷潮在线观看|国产AⅤ精品一区二区久久|中文字幕AV中文字幕|国产看片高清在线

    dom樣式編程
    來源:易賢網(wǎng) 閱讀:1237 次 日期:2016-06-29 08:50:51
    溫馨提示:易賢網(wǎng)小編為您整理了“dom樣式編程”,方便廣大網(wǎng)友查閱!

    dom樣式編程,簡單的理解就是通過javascript來操作頁面元素的屬性,來改變頁面顯示效果。頁面中通過引入style對象來管理元素的css屬性。dom也采用style對象來管理。

    style對象包含與每個css樣式對應的特性,雖然格式不同,單個單詞的css樣式,以相同名字的特性來表示,但是style對象中,兩個單詞的樣式的表示方式是通過將第一個單詞加

    上首字母大寫的第二個殘次,并且單詞間沒有橫杠。

    下面列出了一些常用的css特性以及她們對應的javascript中style對象的表示

    css樣式特性 javascript樣式特性

    background-color style.backgroundcolor

    color style.color

    font style.font

    font-family style.fontfanmily

    font-weight style.fontweight

    以上是舉了幾個簡單的例子。

    <html>

    <title>網(wǎng)站制作學習網(wǎng)</title>

    <head>

    <script language=javascript>

    function forasp_cn()

    {

    var forasp_cn_div = document.getelementbyid(forasp_div);

    alert(原來顏色是+forasp_cn_div.style.backgroundcolor+\n點擊后變?yōu)間reen);

    forasp_cn_div.style.backgroundcolor = green;

    }

    </script>

    </head>

    <body>

    <div id=forasp_div style=background-color:red; onclick= forasp_cn();>網(wǎng)站制作學習網(wǎng)點擊看看</div>

    </body>

    </html>

    style對象還有csstext特性,這個特性包含了所有描述元素樣式的css字符串。

    用法:對象.style.csstext。這樣就獲取了全部的style的樣式內容。

    dom樣式的方法

    getpropertyvalue(properyname)-返回css特性propertyname的字符串值。特性必須按照css樣式定義。例如background-color而不是backgroundcolor;

    getpropertypriority()-如果在規(guī)則中指定特性important,則返回important,否則返回空的字符串。

    item(index)-返回在給定索引的index處的css特性的名稱,稱background-color;

    removeproperty(propertyname)-從css定義中刪除propertyname

    setproperty(propertyname,value,priority)-按照指定的優(yōu)先級priority來設置css特性propertyname的value值(priority的值可以為impertinent或者為空字符串)

    更多信息請查看腳本欄目
    易賢網(wǎng)手機網(wǎng)站地址:dom樣式編程

    2025國考·省考課程試聽報名

    • 報班類型
    • 姓名
    • 手機號
    • 驗證碼
    關于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點 | 投訴建議
    工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務許可證:(云)人服證字(2023)第0102001523號
    聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關注公眾號:hfpxwx
    咨詢QQ:1093837350(9:00—18:00)版權所有:易賢網(wǎng)