我的漫漫程序之旅

          專注于JavaWeb開發(fā)
          隨筆 - 39, 文章 - 310, 評論 - 411, 引用 - 0
          數(shù)據(jù)加載中……

          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

          主站蜘蛛池模板: 孟村| 筠连县| 聂拉木县| 周宁县| 高州市| 将乐县| 阿鲁科尔沁旗| 饶河县| 花垣县| 平利县| 东港市| 洞头县| 工布江达县| 淮安市| 宁都县| 安远县| 常德市| 通山县| 双牌县| 嘉荫县| 南涧| 陆河县| 蚌埠市| 耿马| 余庆县| 当涂县| 库伦旗| 万源市| 苏尼特右旗| 望奎县| 丽江市| 和林格尔县| 阿瓦提县| 博兴县| 合山市| 文安县| 益阳市| 澄城县| 囊谦县| 民丰县| 建平县|