隨筆-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秒自動關閉頁面
              <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阿頭 閱讀(257) 評論(0)  編輯  收藏 所屬分類: WEB開發(fā)

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


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

          留言簿

          隨筆分類

          隨筆檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜



          主站蜘蛛池模板: 日土县| 景泰县| 济阳县| 藁城市| 巴林左旗| 台江县| 胶州市| 新疆| 民和| 新化县| 沙湾县| 双鸭山市| 广德县| 丰宁| 顺平县| 饶河县| 山东省| 武隆县| 田东县| 射洪县| 郧西县| 汝阳县| 伊春市| 南和县| 万盛区| 新安县| 恭城| 泸西县| 吴江市| 道孚县| 盘锦市| 大安市| 定结县| 壶关县| 什邡市| 武山县| 讷河市| 安溪县| 赣州市| 扶绥县| 永福县|