隨筆-19  評論-5  文章-3  trackbacks-0
          搜集的可能大家平時沒有注意的,但是比較實用的JS代碼:

          (1)點擊文字實現checkbox選項的選定或取消
              <input type="checkbox" name="chk" value="chk1" id="idChk1">
              <label for="idChk1">點擊選定或取消1</label><br>
              <input type="checkbox" name="chk" value="chk2" id="idChk2">
              <label for="idChk2">點擊選定或取消2</label><br>

          (2)點擊文字實現radio選項的選定
              <input type="radio" name="rad" value="rad1" id="idRad1">
              <label for="idRad1"> 點擊選定</label><br>
              或者
              <label for="idRad1"><input type="radio" name="rad" id="idRad1" >imdosop</label>

          (3)顯示文檔最后修改日期
               <script language="javascript">
               document.write(document.lastModified)
               </script>

          (4)傳遞對象form
                <form name="fm1" >
                <input type="text" name="txt" value="rad1" onblur="showForm(this.form);" > 
                </form>
                <form name="fm2" >
                <input type="text" name="txt" value="rad1" onblur="showForm(this.form);" > 
                </form>
               <script language="javascript">
               function showForm(fm){
                    alert(fm.name);
                    alert(fm.txt.value);
                    fm.txt.value="222";
                    alert(fm.txt.value);
               }
               </script>

          (5)過10秒自動關閉頁面
              <script language="JavaScript" >
                  setTimeout("self.close()",10000);
              </script>

          (6)改變水平線的特征
              <hr size="0" noshade color="#C0C0C0">

          (7)在網頁上顯示實時時間
              <script language="javascript">
              window.onload=function(){
                  setInterval("document.fm.txtclock.value=(new Date);",1000);
              }
              </script>

          (8)判斷cookie是否可用
              <script language="javascript">
              window.onload=function(){
                   if(navigator.cookieEnabled){
                       alert("Cookie可用");
                   }
              }
              </script>

          (9)截取小數點后兩位
              window.onload=function(){
                  var a=3454545.4454545;
                  alert(a.toFixed(2));
              }

          (10)動態改變字體大小
              function reSize(size) {
                  document.getElementById('imdosop').style.fontSize = size+'px';
              }

          會繼續補充,也請大家把自己掌握的貼出來共享。。。


          天天學習,好好向上——

          posted on 2011-12-30 15:30 東頭bing阿頭 閱讀(254) 評論(0)  編輯  收藏 所屬分類: WEB開發

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           



          主站蜘蛛池模板: 桃园市| 隆化县| 洛南县| 根河市| 乌审旗| 大冶市| 徐州市| 罗田县| 鄂托克旗| 德保县| 阿拉善右旗| 琼中| 前郭尔| 张北县| 新疆| 五台县| 无为县| 沿河| 合作市| 石首市| 车致| 湄潭县| 光泽县| 禄劝| 获嘉县| 平顺县| 卫辉市| 庄浪县| 介休市| 安乡县| 北宁市| 亳州市| 陆川县| 疏勒县| 长岭县| 丽水市| 海宁市| 深州市| 扎赉特旗| 潍坊市| 余江县|