我的漫漫程序之旅

          專注于JavaWeb開發(fā)
          隨筆 - 39, 文章 - 310, 評論 - 411, 引用 - 0

          導(dǎo)航

          <2025年7月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          常用鏈接

          留言簿(39)

          隨筆檔案(43)

          文章分類(304)

          文章檔案(257)

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          Prototype1.6 實戰(zhàn)05 (Element)

          <HTML>
           
          <HEAD>
            
          <TITLE> Element </TITLE>
          <script src="prototype.js" type="text/javascript" /></script>
          <style>
              .luck
              
          {
                  color 
          :  red;
              
          }

          </style>
            
          <script>
                  
          function _insert()
                  
          {    
                      
          //檢查d1元素內(nèi)是否有值
                      if(!$('d1').empty())
                      
          {
                          alert($('d1').outerText);
                      }

                      
          //第一人參數(shù)<position,即要在哪添加>,第二個參數(shù)即要添加的內(nèi)容
                      Element.insert("d1","<input type='text' />");
                      
          //直接指定元素的insert也可以,直接在參數(shù)里傳內(nèi)容
                      $('d1').insert("<img src='' />");
                  }


                  
          function _remove()
                  
          {
                      $('d1').remove();
                      
          //或用Element.remove('d1');
                  }


                  
          function _replace()
                  
          {
                      $('d1').replace(
          "<div id='d1'>QQ</div>");
                  }


                  
          function _addClass()
                  
          {
                      $('t1').addClassName('luck');
                  }


                  
          function _removeClass()
                  
          {
                      $('t1').removeClassName('luck');
                  }


                  
          function _hide()
                  
          {
                      $('t1').hide();
                  }


                  
          function _show()
                  
          {
                      $('t1').show();
                  }


            
          </script>
           
          </HEAD>

           
          <BODY>
              
          <div id="d1">
                      dtest
              
          </div>
              
          <input type="button" value="添加" onclick="_insert();"/>
              
          <input type="button" value="替換" onclick="_replace();"/>
              
          <input type="button" value="刪除" onclick="_remove();"/>
              
          <input type="text" value="請注意查看文字顏色" id="t1"/>
              
          <input type="button" value="添加class" onclick="_addClass()" />
              
          <input type="button" value="移除class" onclick="_removeClass()" />
              
          <input type="button" value="隱藏" onclick="_hide()" />
              
          <input type="button" value="顯示" onclick="_show()" />
              
          <div id="framer">   <img src="http://www.baidu.com/img/baidu.gif" alt="點此還原為原來大小" onclick="$('framer').undoClipping();"/> </div> 
           
          </BODY>
           
          <script>
              (
          function()
                  
          {
                      
          //剪切層的大小 
                      $('framer').makeClipping().setStyle({width: '100px' ,height: '100px'});
                  }
          )();

              
           
          </script>
          </HTML>


          posted on 2008-07-23 17:37 々上善若水々 閱讀(321) 評論(0)  編輯  收藏 所屬分類: JavaScript

          主站蜘蛛池模板: 铜鼓县| 钟山县| 江口县| 盐城市| 渝中区| 泽普县| 广元市| 武平县| 沙河市| 正镶白旗| 马关县| 古交市| 泰州市| 建瓯市| 永州市| 湘潭县| 栖霞市| 永福县| 社会| 鄂尔多斯市| 永康市| 齐河县| 金华市| 睢宁县| 墨江| 韩城市| 上蔡县| 海兴县| 镇安县| 宁明县| 杭州市| 河源市| 昌平区| 衡阳市| 木里| 宁安市| 汶上县| 弥勒县| 张家川| 巴彦淖尔市| 洞口县|