有關多選與單選(轉載) 取得連結 Facebook X Pinterest 以電子郵件傳送 其他應用程式 7月 21, 2016 $(".grpCbx").click(function() { $(".grpCbx").not(this).removeAttr("checked"); }); 將其他check清空,使用專屬jquery的 .not(this) 來處理 原出處 http://blog.darkthread.net/post-2009-05-29-something-about-js-event.aspx 取得連結 Facebook X Pinterest 以電子郵件傳送 其他應用程式 留言
iOS Safari 中點擊事件失效的解決辦法(轉貼) 11月 30, 2016 iOS Safari 中點擊事件失效的解決辦法 問題描述 當使用委託給一個元素添加click事件時,如果事件是委託到 document 或 body 上,並且委託的元素是默認不可點擊的(如 div, span 等),此時 click 事件會失效。 可以使用下面的代碼在 iOS 中進行測試。 <!DOCTYPE html> < html > < head > < meta charset = "UTF-8" > < meta name = "viewport" content = "width=device-width" > < title > iOS click bug test </ title > < style > .container { } .target { display : block; text-align : center; margin : 100px 30px 0 ; padding : 10px 0 ; border : 1px solid #ccc ; } </ style > </ head > < body > < div class = "container" > < div class = "target" > Click Me! </ div > </ div > < script src = "//code.jquery.com/jquery-2.1.4.min.js" > </ script > < scrip... 閱讀完整內容
jQuery獲取Select選擇的Text和Value(轉) 7月 19, 2016 jQuery獲取Select選擇的Text和Value(轉) jQuery獲取Select選擇的Text和Value: 語法解釋: 1. $("#select_id").change(function(){//code...}); //為Select添加事件,當選擇其中一項時觸發 2. var checkText=$("#select_id").find("option:selected").text(); //獲取Select選擇的Text 3. var checkValue=$("#select_id").val() ; //獲取Select選擇的Value 4. var checkIndex=$("#select_id ").get(0).selectedIndex; //獲取Select選擇的索引值 5. var maxIndex=$("#select_id option:last" ).attr("index"); //獲取Select最大的索引值 jQuery設置Select選擇的Text和Value: 語法解釋: 1. $("#select_id ").get(0).selectedIndex=1; //設置Select索引值為1的項選中 2. $("#select_id ").val(4); //設置Select的Value值為4的項選中 3. $("#select_id option[text='jQuery' ]").attr("selected", true); //設置Select的Text值為jQuery的項選中 jQuery添加/刪除Select的Option項: 語法解釋: 1. $("#select_id").append("<option value='Value'>Text</option>"); //為Select追加一個Option(下拉項) 2. $("#se... 閱讀完整內容
ajax回傳完畢前的讀取畫面、css置中等功能 7月 21, 2016 要完全置中(上下左右) < style > . dialogbox { top : 0 ; left : 0 ; bottom : 0 ; right : 0 ; margin : auto ; overflow : auto ; } </ style > 在ajax的運用中使用,用途為若api未回傳資料回來,就插入畫面擋住不讓用戶一直點擊 CSS div . loadingdiv { height : 100 %; /*100% 覆蓋網頁內容 , 避免 user 在 loading 時進行其他操作 */ width : 100 %; position : fixed ; z-index : 99999 ; /* 須大於網頁內容 */ top : 0 ; left : 0 ; display : block ; background : #000 ; opacity : 0.6 ; text-align : center ; } div . loadingdiv img { position : relative ; vertical-align : middle ; text-align : center ; margin : 0 auto ; margin-top : 50 vh ; } Ajax 主要是在beforeSend跟complete這兩個function 若開始執行 show,若完成就hide。 AjaxCall : function ( urlStr , object , callback ) { console. log ([ urlStr , object ]); $ . ajax ({ url: urlStr , type: "GET" , data: object , dataType: "json" , suc... 閱讀完整內容
留言
張貼留言