JQuery學習一,JQuery學習
學習JQuery,如何建立、調用和關閉強制回應視窗。
(document).ready(function() {/* Background Resizer-背景自適應瀏覽器大小 */$("#bodyBackground").ezBgResize();/* modal windows */$('a.modal').click(function() {/*attr-擷取屬性值,例如tagName*/ var modalID = $(this).attr('rel'); // get the name of the modal /* fade in the modal window and add a close button to it *//**fadeIn-淡入已隱藏的元素*prepend-在被選元素的開頭插入內容*/ $('#' + modalID).fadeIn().prepend('<a href="#" class="close"><img src="grfx/close_button.png" class="close_button" title="Close Window" alt="Close" /></a>'); /* * define the margins so that the modal is centered properly on the screen * we add 80px to the height/width to accomodate for the padding and border * width defined in the css */ var modalMarginTop = ($('#' + modalID).height() + 80) / 2; var modalMarginLeft = ($('#' + modalID).width() + 80) / 2; /* apply the margins to the modal window */ $('#' + modalID).css({ 'margin-top' : -modalMarginTop, 'margin-left' : -modalMarginLeft }); /* fade in the shade! (tired of the cheesy jokes yet?) *//*append-被選元素的結尾插入內容。*/ $('body').append('<div id="modalShade"></div>'); // add the shade layer to bottom of the body $('#modalShade').css('opacity', 0.7).fadeIn(); // set the opacity with jQuery to avoid all of the nasty CSS needed for IE return false; // keep the link from acting naturally }); /* * close the modal and pull down the shade */ /*live-綁定事件函數,文法是$(selector).live(event,data,function),live函數不支援DOM遍曆*/ $('a.close, #modalShade').live('click', function() { // clicking on the close or shade layer/*parent-返回被選元素的直接父元素,方法只會向上一級對 DOM 樹進行遍曆*/ var thisModalID = $('a.close').parent().attr('id'); $('#modalShade, #'+thisModalID).fadeOut(function() {/* remove-刪除被選元素(及其子項目),該方法也可接受一個參數,允許您對被刪元素進行過濾。例如指定過濾class為del的remove('.del')*/ $('#modalShade, a.close').remove(); // remove the shade and the close button }); return false; });
我要學習jquery,但是不知道哪個版本的jquery學起來比較好一點,可以推薦推薦,我是一個jquery的初學者
考慮到中國的瀏覽器環境,建議學1.9及後續的1.*版本,1.*版本都有個基本的相容性,所以1.7.2的那個建議直接無視之。況且那個版本的文檔也不好找了。
jQuery怎麼學?
1、看文檔,改樣本,認真地看一下官網的文檔,同時對文檔中的樣本在自己的瀏覽器下跑一下,同時對這些樣本根據自己的設計意見改一下,加深對代碼的理解。
2、如果你想學深一點,那就是看jQuery本身的代碼。
學習jquery有沒有什好一點的書籍?
個人認為www.w3school.com.cn上的JQuery知識有點老了,給你推薦個網址www.css88.com/jqapi-1.9這是中文版的JQuery API 我相信對你學習JQuery會有莫大的協助的!同意的話就採納吧,謝謝!