生活随笔
收集整理的這篇文章主要介紹了
jquery笔记(常用技术)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1.選擇器?????????(1)通配符:?????????$("input[id^='code']");??????$("input[id$='code']");??????$("input[id*='code']");??????(2)根據索引選擇?????????$("tbody?tr:even");???????$("tbody?tr:odd");????????(3)獲得jqueryObj下一級節點的input個數?????????jqueryObj.children("input").length;?????????(4)獲得class為main的標簽的子節點下所有<a>標簽?????????$(".main?>?a");??????????(5)選擇緊鄰標簽?????????jqueryObj.next("div");??????(6)根據索引選擇?????????$("div").eq(0);??2.篩選器?????????(1)not?????????$("#code?input:not([id^='code'])");??3.其他?????????(1)創建一個文本框?????????var?inputObj?=?$("<input?type='text'/>");?????????(2)取得文本框內容?????????jqueryObj.html();??????jqueryObj.text();??????(3)取得標簽屬性值?????????jqueryObj.val();??????jqueryObj.attr("屬性名如:name");??????(4)向dom節點添加對象?????????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)定時間隔時間??????var?timerId?=?setInterval(function(){??},300);??????clearInterval(timerId);??????(8)動畫??????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.工具函數?????????$('#someField').val($.trim($('#someField').val()));??7.常用函數封裝?????????(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("沒有選中記錄");???????????????????????????????}?????????????????????else?{?????????????????????????var?ids?=?"";?????????????????????????checkboxs.each(function(){?????????????????????????????if(ids==''){?????????????????????????????????ids+=$(this).attr('id');?????????????????????????????}?????????????????????????????else{?????????????????????????????????ids+=","+$(this).attr('id');?????????????????????????????}?????????????????????????})?????????????????????????return?ids;?????????????????????}?????????????????}?????????????})?????????})(jQuery); ? ?
轉載于:https://www.cnblogs.com/wangbin/archive/2011/06/15/2081369.html
總結
以上是生活随笔為你收集整理的jquery笔记(常用技术)的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。