我的漫漫程序之旅

          專注于JavaWeb開發
          隨筆 - 39, 文章 - 310, 評論 - 411, 引用 - 0
          數據加載中……

          Prototype1.6 實戰05 (Element)

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

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

                      
          //第一人參數<position,即要在哪添加>,第二個參數即要添加的內容
                      Element.insert("d1","<input type='text' />");
                      
          //直接指定元素的insert也可以,直接在參數里傳內容
                      $('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 々上善若水々 閱讀(322) 評論(0)  編輯  收藏 所屬分類: JavaScript

          主站蜘蛛池模板: 沂南县| 南江县| 福泉市| 黄浦区| 永仁县| 玛曲县| 神农架林区| 陵水| 江阴市| 大同市| 齐齐哈尔市| 斗六市| 太康县| 灌阳县| 汝州市| 永春县| 石渠县| 永新县| 含山县| 太仓市| 邮箱| 峨边| 江北区| 织金县| 大悟县| 梨树县| 永年县| 焉耆| 新绛县| 三穗县| 阿拉善右旗| 西城区| 临澧县| 镇雄县| 邓州市| 凤山县| 大姚县| 盐源县| 盐津县| 泸定县| 衡阳市|