- <!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>
- <title>無標題頁</title>
- <script type="text/javascript" src="js/jquery-1[1].2.6.min.js"></script>
-
- <style type="text/css">
- .over {
- background:Red; /*這個將是滑鼠高亮行的背景色*/
- }
- .color{
- background:Green;
- }
- </style>
-
- <script type="text/javascript">
- $(document).ready(function() {
- $("#user").mouseover(function(){
- $(this).removeClass("color").addClass("over");
- $(this).attr("height","100px");
- })
- .mouseout(function(){
- $(this).removeClass("over").addClass("color");
- });
- })
- </script>
- </head>
- <body>
- <div id="user" class="color">滑鼠移動過來</div>
- </body>
- </html>
http://wiki.jquery.org.cn/doku.php
- <!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>
- <title>無標題頁</title>
- <script type="text/javascript" src="js/jquery-1[1].2.6.min.js"></script>
-
- <style type="text/css">
- .over {
- background:Red; /*這個將是滑鼠高亮行的背景色*/
- }
- .color{
- background:Green;
- }
- </style>
-
- <script type="text/javascript">
- /*
- 此教程目的是讓那些新手通過實際應用,對jquery有一個初步瞭解。
- 傳說中的ready
- $(document).ready() 作用就是 在頁面載入完成之後執行 封裝在裡面的js.
- 你可以在一個頁面中使用任意多個$(document).ready事件
- */
- /*----------------傳說中的ready-------------------*/
- $(document).ready(function() {
- /*------------------end-----------------*/
-
- /*jQuery的鏈式操作
- 正常情況下應該寫成
- $("#user").mouseover(function(){
- $(this).addClass("over");
- });
- $("#user").mouseout(function(){
- $(this).removeClass("over");
- });
-
- 但是我們現在寫成 $("#user").mouseover().mouseout()這種形式;
- 因為 在jQuery中,執行完mouseover或者mouseout等方法之後,都會返回當前的對象,所以可以進行鏈式操作
- */
- /*----------------鏈式操作例子-------------------*/
- $("#user").mouseover(function(){
- $(this).removeClass("color").addClass("over");
- $(this).attr("height","100px");
- })
- .mouseout(function(){
- $(this).removeClass("over").addClass("color");
- });
- /*-----------------end-----------------*/
- })
- </script>
- </head>
- <body>
- <div id="user" class="color">滑鼠移動過來</div>
- </body>
- </html>
去掉注釋,清晰一些