標籤:bs jquery
What is jQuery?
jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript.
特點:
Write less,Do more
jQeury is designed to change the way whta you write JavaScirpt;
以強大的CSS選取器為基礎,幾乎所有操作都先使用選取器尋找DOM對象,然後對齊進行各種操作。
屏蔽瀏覽器差異,對DOM的操作提供了方便的擴充,易用的事件處理API和動畫API.
使用方法:
在需要使用jQuery的頁面中引入jQuery的js檔案即可
<script type="text/javascript" src="js/jquery.js"></script>
jQuery對js開發四部分的完美實現
對於JS來說
1,、對於j尋找DOM元素進行取值和賦值的操作、在特定節點位置進行內容的取值和複製操作。
2、針對元素進行事件監聽。
3、通過操作DOM節點結合改變元素的CSS樣式,達到絢麗的動畫效果。
4、對DOM元素進行Ajax操作。
對於jQuery來說
1、jQuery擁有強大的選取器,可以尋找任意的DOM元素。同時jQuery對象實現鏈式文法,能夠很方便的寫出強大的操作。比如操作屬性:
$("#chkbox").attr("checked","checked").attr("disabled","disabled").可以這樣繼續連結下去,包括增加事件、樣式等操作。
2、在頁面載入時給DOM綁定事件。$("chkbox").click(function(){alert("hello jquery");});
3、show()和hide()是jQuery中最基本的動畫。對元素顯示和隱藏,通過fadeOut和fadeIn可以實現淡出淡入的效果。
4、$.ajax(options)是jQuery中最底層的Ajax實現。還可以使用$.get()或$.post()實現Ajax請求。
待續。。。
JQuery學習總結