jQuery學習-設定訪問元素樣式

來源:互聯網
上載者:User

標籤:script   偶數   密碼   html   載入   asc   function   擷取   使用者   

 

<!DOCTYPE html><html>    <head>        <meta charset="UTF-8">        <title>訪問與設定元素樣式</title>        <script src="js/jquery.js"></script>        <style>            .divstyle{                                border: 5px solid black;                background-color: silver;            }            .trstyle{                                background-color: lightskyblue;;                color: black;            }            .        </style>            <script type="text/javascript">                //頁面載入完成簡寫形式            $(function(){                                //設定儲存格寬度100px                //$("td").css("width","300px");                //$("td").css("font-size","30px");                //$("td").css("color","red");                //$("td").css("border","1px solid red");                $("td").css({"width":"300px","font-size":"30px","color":"red","border":"1px solid red"})                                //擷取div背景顏色,css可以設定元素屬性,也可以擷取css屬性                var color= $("div").css("background-color");                alert(color);                                //設定斑馬線,隔行背景顏色變成藍色,字型變黑色  odd偶數行,如果同時設定多個類加,號隔開                $("tr:odd").addClass("trstyle");                                //移出對應元素的css樣式,移出DIV的樣式,如果不穿參數,則表示移出所有CSS樣式                $("div").removeClass("divstyle");            })                </script>    </head>    <body>        <div class="divstyle">            <table>                <tr><td>使用者名稱1</td><td>密碼1</td></tr>                <tr><td>使用者名稱2</td><td>密碼2</td></tr>                <tr><td>使用者名稱3</td><td>密碼3</td></tr>                <tr><td>使用者名稱4</td><td>密碼4</td></tr>                <tr><td>使用者名稱5</td><td>密碼5</td></tr>                <tr><td>使用者名稱6</td><td>密碼6</td></tr>                <tr><td>使用者名稱7</td><td>密碼7</td></tr>                <tr><td>使用者名稱8</td><td>密碼8</td></tr>                <tr><td>使用者名稱9</td><td>密碼9</td></tr>                <tr><td>使用者名稱10</td><td>密碼10</td></tr>            </table>        </div>    </body></html>

 

jQuery學習-設定訪問元素樣式

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.