標籤: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>
: