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

          (1)點擊文字實現(xiàn)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)點擊文字實現(xiàn)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秒自動關(guān)閉頁面
              <script language="JavaScript" >
                  setTimeout("self.close()",10000);
              </script>

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

          (7)在網(wǎng)頁上顯示實時時間
              <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)截取小數(shù)點后兩位
              window.onload=function(){
                  var a=3454545.4454545;
                  alert(a.toFixed(2));
              }

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

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


          天天學習,好好向上——

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

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


          網(wǎng)站導航:
           
          <2011年12月>
          27282930123
          45678910
          11121314151617
          18192021222324
          25262728293031
          1234567

          留言簿

          隨筆分類

          隨筆檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜



          主站蜘蛛池模板: 婺源县| 兴文县| 米泉市| 米易县| 九江县| 德昌县| 景谷| 弥渡县| 光山县| 泰和县| 吉林市| 廊坊市| 醴陵市| 麟游县| 富川| 晋城| 五常市| 鞍山市| 泌阳县| 台州市| 长岛县| 五台县| 城市| 花莲市| 天柱县| 玛多县| 桂阳县| 进贤县| 马公市| 三门县| 天门市| 高碑店市| 疏附县| 封开县| 元江| 隆尧县| 永定县| 元谋县| 塔城市| 闽清县| 丹巴县|