亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

JQuery Study Notes 學習筆記(一)

 更新時間:2010年08月04日 02:03:10   作者:  
jquery是當前比較流行的js類庫,學習它可以實現(xiàn)很多功能。
1. 使用jquery
  到j(luò)query.com下載jquery.js當前版本是1.4.2
  新建一個html頁面
復制代碼 代碼如下:

<!DOCTYPE html><BR><html lang="en"><BR><head><BR>&nbsp;&nbsp; <meta http-equiv="Content-Type" content="text/html; charset=utf-8"><BR>&nbsp;&nbsp;<script type="text/javascript" src="<SPAN style="COLOR: #ff0000"><STRONG>jquery.js</STRONG></SPAN>"></script></PRE>
<PRE class=brush>&nbsp;&nbsp; <script type="text/javascript"><BR>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000"> $(document).ready(function(){</SPAN><BR><SPAN style="COLOR: #ff0000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $("a").click(function(event){</SPAN><BR><SPAN style="COLOR: #ff0000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert("As you can see, the link no longer took you to jquery.com");</SPAN><BR><SPAN style="COLOR: #ff0000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; event.preventDefault();</SPAN><BR><SPAN style="COLOR: #ff0000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; });</SPAN><BR><SPAN style="COLOR: #ff0000">&nbsp;&nbsp;&nbsp;&nbsp; });</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp; </script><BR></head><BR><body><BR>&nbsp;&nbsp; <a href="<A class="external free" >jQuery</a><BR></body><BR></html>

代碼解釋:
  $(document).ready(function(){...})在頁面加載完時添加function()函數(shù)內(nèi)容
  $("a").click(function(event){...})設(shè)置a標簽的click事件函數(shù)
  event.preventDefault()阻止原事件執(zhí)行
  代碼功能:點擊<a>標簽只彈出alert信息后,頁面并不跳轉(zhuǎn)到http://jquery.com/。
2. 添加和移除HTML class
  首先在<head>中添加一些樣式,例如:
復制代碼 代碼如下:

<style type="text/css">
a.test { font-weight: bold; }
</style>

在script中使用addClass和removeClass來添加和移除HTML class,例如:
復制代碼 代碼如下:

$("a").addClass("test");//所有a標記粗體
$("a").removeClass("test");//取消所有a標記粗體

3.特效
  jQuery提供了一些非常方便的特效
復制代碼 代碼如下:

$("a").click(function(event){
event.preventDefault();
$(this).hide("slow");
});

點擊<a>標簽后,標記慢慢消失
4.回調(diào)與函數(shù)
  無參數(shù)回調(diào)
復制代碼 代碼如下:

$.get('myhtmlpage.html', myCallBack);

帶參數(shù)回調(diào)
復制代碼 代碼如下:

$.get('myhtmlpage.html', function(){
myCallBack(param1, param2);
});

相關(guān)文章

最新評論