第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

用jquery實現(xiàn)雙色表格,鼠標移動到上面時,行變色~!

標簽:
JQuery

         这里我直接贴上代码,在代码上稍作解释:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
        <title>无标题页</title> 
//导入jquery库文件~!
        <. type="text/." src="../JS/jquery.js"></.>
        <. language =. > 
//html载入完毕后运行$(document).ready()  $(document).ready(function(){ //为类型名为csstab标签的tr子标签添加mouseover 和 mouseout方法,mouseout在mouseover 后执行,addClass和removeClass分别添加类和移除类样式~!
     $(".csstab tr").mouseover(function(){$(this).addClass("over");}).mouseout(function(){$(this).removeClass("over");}) //为偶数tr,添加样式~!
     $(".csstab tr:even").addClass("alt");
        });
        </.>
<style type ="text/css" >
th {
                background:#0066FF;
                color:#FFFFFF;
                line-height:20px;
                height:30px;
}
td {
                padding:6px 11px;
                border-bottom:1px solid #95bce2;
                vertical-align:top;
                text-align:center;
}
    
td * {
                padding:6px 11px;
}
tr.alt td {
                background:#ecf6fc;    /*这行将给所有的tr加上背景色*/
}
    
tr.over td {
                background:#bcd4ec;    /*这个将是鼠标高亮行的背景色*/
                cursor:pointer;
}

</style>
</head>
<body>
        <h1>
                用jquery实现双色表格,鼠标移动到上面时,行变色~!</h1>
        <form id="form1" runat="server">
                <div>
                        <table width =400 class ="csstab" cellspacing =0>
                                <thead>
                                        <tr>
                                                <th>
                                                        姓名</th>
                                                <th>
                                                        年龄</th>
                                                <th>
                                                        性别</th>
                                                <th>
                                                        QQ</th>
                                        </tr>
                                </thead>
                                <tbody>
                                        <tr>
                                                <td>
                                                        opper</td>
                                                <td>
                                                        23</td>
                                                <td>
                                                        男</td>
                                                <td>
                                                        56791700</td>
                                        </tr>
                                        <tr>
                                                <td>
                                                        opper</td>
                                                <td>
                                                        23</td>
                                                <td>
                                                        男</td>
                                                <td>
                                                        56791700</td>
                                        </tr>
                                        <tr>
                                                <td>
                                                        opper</td>
                                                <td>
                                                        23</td>
                                                <td>
                                                        男</td>
                                                <td>
                                                        56791700</td>
                                        </tr>
                                        <tr>
                                                <td>
                                                        opper</td>
                                                <td>
                                                        23</td>
                                                <td>
                                                        男</td>
                                                <td>
                                                        56791700</td>
                                        </tr>
                                        <tr>
                                                <td>
                                                        opper</td>
                                                <td>
                                                        23</td>
                                                <td>
                                                        男</td>
                                                <td>
                                                        56791700</td>
                                        </tr>
                                        <tr>
                                                <td>
                                                        opper</td>
                                                <td>
                                                        23</td>
                                                <td>
                                                        男</td>
                                                <td>
                                                        56791700</td>
                                        </tr>
                                </tbody>
                        </table>
                </div>
        </form>
</body>
</html>
自己可考代码看下运行效果~! 这里有一个jQuery的技巧不得不提一下:jQuery的链式操作,什么是链式操作呢? 我们来看看,本来应该写成这样子的: $(".stripe tr").mouseover(function(){    
                $(this).addClass("over");})    
$(".stripe tr").mouseout(function(){    
                $(this).removeClass("over"); })但是我们写成了: $(".stripe tr").mouseover(function(){    
                         $(this).addClass("over");}).mouseout(function(){    
                                 $(this).removeClass("over");})在jQuery中,执行完mouseover或者mouseout等方法之后,都会返回当前的对象,所以可以进行链式操作

點擊查看更多內(nèi)容
TA 點贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優(yōu)質(zhì)文章

正在加載中
  • 推薦
  • 評論
  • 收藏
  • 共同學習,寫下你的評論
感謝您的支持,我會繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦
今天注冊有機會得

100積分直接送

付費專欄免費學

大額優(yōu)惠券免費領(lǐng)

立即參與 放棄機會
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號

舉報

0/150
提交
取消