有關多選與單選(轉載) 取得連結 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 以電子郵件傳送 其他應用程式 留言
使用jQuery對 select 的操作(本文為網路找到的參考文) 6月 30, 2016 [jQuery] 使用 jQuery 對 select 的操作 1. 取得選擇項目的文字與值 /*----- 單選 -----*/ // 取得被選擇項目的文字 $ ( "#select" ). find ( ":selected" ). text (); // 取得被選擇項目的值 $ ( "#select" ). find ( ":selected" ). val (); /*----- 多選 -----*/ // 使用迴圈取得所有被選擇的項目 $ ( "#select" ). find ( ":selected" ). each ( function () { alert ( this . text ); // 文字 alert ( this .value); // 值 }); 2. 增加項目 $ ( "#select" ). append ( $ ( "<option></option>" ). attr ( "value" , " 值 " ). text ( " 文字 " )); 3. 移除選擇的項目 // 移除選擇的項目 $ ( "#select" ). find ( ":selected" ). remove (); // 移除全部的項目 $ ( "#select option " ). remove (); 4. 移除選擇項目後,防止捲軸移到最上面 // 先取得要移除項目的 index var selectIndex = $ ( "#select" ). find ( ":selected" ). index (); // 移除選擇的項目 $ ( "#select" ). find ( ":selected" ). remove (); // 判斷移除項目後,原先的 inde... 閱讀完整內容
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... 閱讀完整內容
多執行緒的使用 7月 04, 2017 基本上多執行緒已經搞了一段時間,仍然是偶有失誤 這裡試著記錄下來這次任務的寫法 需求:開一個執行緒,持續去執行某行程式 private Handler mThreadHandler; private HandlerThread mThread; private void bleTimeCheck() { mThread = new HandlerThread("name"); mThread.start(); mThreadHandler = new Handler(mThread.getLooper()); mThreadHandler.postDelayed(r1, 3000); } private Runnable r1 = new Runnable() { public void run() { // TODO Auto-generated method stub Calendar c1 = Calendar.getInstance(); Log.e("0704.1 Time", "" + c1.getTimeInMillis()); mThreadHandler.postDelayed(r1, 3000); } }; 使用這個寫法,可以順利的讓執行緒每隔三小持續執行裡面run()裡面的東西 其實這次主要是 import的時候選錯class ,結果卡超久 所以上面這段程式複製使用會出現紅字的話,那非常大的機會是import選錯class,重新import即可 在撰寫過程中主要是參考這個網址 http://j796160836.pixnet.net/blog/post/29895257 閱讀完整內容
留言
張貼留言