欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jQuery事件綁定用法詳解

 更新時間:2016年09月08日 09:37:56   作者:onestopweb  
這篇文章主要介紹了jQuery事件綁定用法,結(jié)合多個實例較為詳細的分析了常見的jQuery事件綁定實現(xiàn)技巧與使用方法,需要的朋友可以參考下

本文實例講述了jQuery事件綁定。分享給大家供大家參考,具體如下:

style.css

*{margin:0;padding:0;}
body { font-size: 13px; line-height: 130%; padding: 60px }
#panel { width: 300px; border: 1px solid #0050D0 }
.head { padding: 5px; background: #96E555; cursor: pointer }
.content { padding: 10px; text-indent: 2em; border-top: 1px solid #0050D0;display:block;display:none; }

demo1.html

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<script type="text/javascript" src="js/jquery-1.10.1.min.js"></script>
<script type="text/javascript">
$(function(){
  $("#panel h5.head").bind("click",function(){
    $(this).next("div.content").show();
  })
})
</script>
</head>
<body>
<div id="panel">
  <h5 class="head">什么是jQuery?</h5>
  <div class="content">
    jQuery是繼Prototype之后又一個優(yōu)秀的JavaScript庫,它是一個由 John Resig 創(chuàng)建于2006年1月的開源項目。
    jQuery憑借簡潔的語法和跨平臺的兼容性,極大地簡化了JavaScript開發(fā)人員遍歷HTML文檔、
    操作DOM、處理事件、執(zhí)行動畫和開發(fā)Ajax。
    它獨特而又優(yōu)雅的代碼風(fēng)格改變了JavaScript程序員的設(shè)計思路和編寫程序的方式。
  </div>
</div>
</body>
</html>

demo2.html

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<script type="text/javascript" src="js/jquery-1.10.1.min.js"></script>
<script type="text/javascript">
$(function(){
  $("#panel h5.head").bind("click",function(){
    var $content = $(this).next("div.content");
    if($content.is(":visible")){
      $content.hide();
    }else{
      $content.show();
    }
  })
})
</script>
</head>
<body>
<div id="panel">
  <h5 class="head">什么是jQuery?</h5>
  <div class="content">
    jQuery是繼Prototype之后又一個優(yōu)秀的JavaScript庫,它是一個由 John Resig 創(chuàng)建于2006年1月的開源項目。
    jQuery憑借簡潔的語法和跨平臺的兼容性,極大地簡化了JavaScript開發(fā)人員遍歷HTML文檔、
    操作DOM、處理事件、執(zhí)行動畫和開發(fā)Ajax。
    它獨特而又優(yōu)雅的代碼風(fēng)格改變了JavaScript程序員的設(shè)計思路和編寫程序的方式。
  </div>
</div>
</body>
</html>

demo3.html

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<script type="text/javascript" src="js/jquery-1.10.1.min.js"></script>
<script type="text/javascript">
$(function(){
  $("#panel h5.head").bind("mouseover",function(){
    $(this).next("div.content").show();
  });
   $("#panel h5.head").bind("mouseout",function(){
     $(this).next("div.content").hide();
  })
})
</script>
</head>
<body>
<div id="panel">
  <h5 class="head">什么是jQuery?</h5>
  <div class="content">
    jQuery是繼Prototype之后又一個優(yōu)秀的JavaScript庫,它是一個由 John Resig 創(chuàng)建于2006年1月的開源項目。
    jQuery憑借簡潔的語法和跨平臺的兼容性,極大地簡化了JavaScript開發(fā)人員遍歷HTML文檔、
    操作DOM、處理事件、執(zhí)行動畫和開發(fā)Ajax。
    它獨特而又優(yōu)雅的代碼風(fēng)格改變了JavaScript程序員的設(shè)計思路和編寫程序的方式。
  </div>
</div>
</body>
</html>

demo4.html

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<script type="text/javascript" src="js/jquery-1.10.1.min.js"></script>
<script type="text/javascript">
$(function(){
  $("#panel h5.head").mouseover(function(){
    $(this).next("div.content").show();
  });
  $("#panel h5.head").mouseout(function(){
     $(this).next("div.content").hide();
  })
})
</script>
</head>
<body>
<div id="panel">
  <h5 class="head">什么是jQuery?</h5>
  <div class="content">
    jQuery是繼Prototype之后又一個優(yōu)秀的JavaScript庫,它是一個由 John Resig 創(chuàng)建于2006年1月的開源項目。
    jQuery憑借簡潔的語法和跨平臺的兼容性,極大地簡化了JavaScript開發(fā)人員遍歷HTML文檔、
    操作DOM、處理事件、執(zhí)行動畫和開發(fā)Ajax。
    它獨特而又優(yōu)雅的代碼風(fēng)格改變了JavaScript程序員的設(shè)計思路和編寫程序的方式。
  </div>
</div>
</body>
</html>

效果圖如下:

更多關(guān)于jQuery相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jQuery常見事件用法與技巧總結(jié)》、《jQuery常用插件及用法總結(jié)》、《jQuery操作json數(shù)據(jù)技巧匯總》、《jQuery擴展技巧總結(jié)》、《jQuery拖拽特效與技巧總結(jié)》、《jQuery表格(table)操作技巧匯總》、《jQuery常見經(jīng)典特效匯總》、《jQuery動畫與特效用法總結(jié)》及《jquery選擇器用法總結(jié)

希望本文所述對大家jQuery程序設(shè)計有所幫助。

相關(guān)文章

最新評論