生活随笔
收集整理的這篇文章主要介紹了
jquery笔记(常用技术)
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1.選擇器?????????(1)通配符:?????????$("input[id^='code']");??????$("input[id$='code']");??????$("input[id*='code']");??????(2)根據(jù)索引選擇?????????$("tbody?tr:even");???????$("tbody?tr:odd");????????(3)獲得jqueryObj下一級(jí)節(jié)點(diǎn)的input個(gè)數(shù)?????????jqueryObj.children("input").length;?????????(4)獲得class為main的標(biāo)簽的子節(jié)點(diǎn)下所有<a>標(biāo)簽?????????$(".main?>?a");??????????(5)選擇緊鄰標(biāo)簽?????????jqueryObj.next("div");??????(6)根據(jù)索引選擇?????????$("div").eq(0);??2.篩選器?????????(1)not?????????$("#code?input:not([id^='code'])");??3.其他?????????(1)創(chuàng)建一個(gè)文本框?????????var?inputObj?=?$("<input?type='text'/>");?????????(2)取得文本框內(nèi)容?????????jqueryObj.html();??????jqueryObj.text();??????(3)取得標(biāo)簽屬性值?????????jqueryObj.val();??????jqueryObj.attr("屬性名如:name");??????(4)向dom節(jié)點(diǎn)添加對(duì)象?????????inputObj.appendTo(jqueryObj);???????inputObj.trigger("focus").trigger("select");??????(5)改變CSS樣式??????inputObj.css({zIndex:3});???????inputObj.css("zIndex");??????(6)延遲?????????var?timeoutId?=?setTimeout(function(){??},300);??????clearTimeout(timeoutId);??????(7)定時(shí)間隔時(shí)間??????var?timerId?=?setInterval(function(){??},300);??????clearInterval(timerId);??????(8)動(dòng)畫??????inputObj.animate{"top":3,"left":3},300,function(){??});??4.事件???????????????jqueryObj.keyup(function(event){?????????????var?keyCode?=?event.which;??????}?????????mouseover(fn),mouseout(fn)??5.效果?????????show(),toggle(),slideDown(),slideUp(),slideToggle(),fadeIn(),fadeOut(),fadeTo()?????6.工具函數(shù)?????????$('#someField').val($.trim($('#someField').val()));??7.常用函數(shù)封裝?????????(function($){?????????????$.extend({???????????????????????????????controlAllCheckBox:function(tableId,isSelectAll){?????????????????????if(tableId==undefined){?????????????????????????throw?new?Error("tableId?不能為空");?????????????????????????????????}?????????????????????else{?????????????????????????if(isSelectAll==undefined){?????????????????????????????throw?new?Error("isSelectAll?不能為空");?????????????????????????????????????}?????????????????????????else{?????????????????????????????if(isSelectAll==true){?????????????????????????????????$("#"+tableId+"?:checkbox").each(function(){?????????????????????????????????????$(this).attr('checked','true');?????????????????????????????????})?????????????????????????????}?????????????????????????????else{?????????????????????????????????$("#"+tableId+"?:checkbox").each(function(){?????????????????????????????????????$(this).attr('checked','');?????????????????????????????????})?????????????????????????????}?????????????????????????}?????????????????????}?????????????????},???????????????????????????????getCheckedIds:function(tableId){?????????????????????var?checkboxs?=?$("#"+tableId+"?:checkbox:checked");?????????????????????if(checkboxs.size()==0){?????????????????????????throw?new?Error("沒(méi)有選中記錄");???????????????????????????????}?????????????????????else?{?????????????????????????var?ids?=?"";?????????????????????????checkboxs.each(function(){?????????????????????????????if(ids==''){?????????????????????????????????ids+=$(this).attr('id');?????????????????????????????}?????????????????????????????else{?????????????????????????????????ids+=","+$(this).attr('id');?????????????????????????????}?????????????????????????})?????????????????????????return?ids;?????????????????????}?????????????????}?????????????})?????????})(jQuery); ? ?
轉(zhuǎn)載于:https://www.cnblogs.com/wangbin/archive/2011/06/15/2081369.html
總結(jié)
以上是生活随笔為你收集整理的jquery笔记(常用技术)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。