【jquery】hover方法

來源:互聯網
上載者:User

標籤:style   blog   class   code   java   ext   

  方法名稱:hover(over, out)

  概述:當滑鼠移動到一個匹配的元素上面時,會觸發指定的第一個函數。當滑鼠移出這個元素時,會觸發指定的第二個函數。

  參數:

    1) overFunction

      滑鼠移到元素上要觸發的函數

    2) outFunction

      滑鼠移出元素要觸發的函數

  例子:

 1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 <title>滑鼠滑過效果</title> 6 <script src="http://files.cnblogs.com/ningvsban/jquery1.8.3.min.js" type="text/javascript"></script>  7 <script type="text/javascript"> 8 $(document).ready(function() { 9     //$("#orderedlist tbody tr").css("text-align","center");10     $("#orderedlist tbody tr").css({"text-align":"center"});11     $("#orderedlist tbody tr").hover(function() {12         $(this).addClass("blue");13     }, function() {14         $(this).removeClass("blue");15     });16 });17 </script>18 <style>19 .blue {20     background:#bcd4ec; 21     cursor:pointer;        22 }23 </style>24 </head>25 <body>26 <table id="orderedlist" width="50%" border="0" cellspacing="0" cellpadding="0"> 27 <thead>28   <tr>29     <th>姓名</th>30     <th>年齡</th>31     <th>QQ</th>32     <th>Email</th>33   </tr>34 </thead>35 <tbody>36   <tr>37     <td>AAAA</td>38     <td>20</td>39     <td>1111</td>40     <td>[email protected]</td>41   </tr>42   <tr>43     <td>BBBB</td>44     <td>21</td>45     <td>2222</td>46     <td>[email protected]</td>47   </tr>48   <tr>49     <td>CCCC</td>50     <td>22</td>51     <td>333</td>52     <td>[email protected]</td>53   </tr>54 </tbody>55 </table>56 </body>57 </html>58 </html>

:

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.