乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      通過js給頁面元素添加事件

       趨明 2012-03-16

       

       
      通過js給頁面元素添加事件,閱讀通過js給頁面元素添加事件,最近做一個登錄仿XP多用戶頁面,要使用js給頁面元素添加事件的方式去處理。網上G了很久找到一個比較簡單的示例:view plaincopy to clipboardprint?script function b(){ alert(
         
       

      最近做一個登錄仿XP多用戶頁面,要使用js給頁面元素添加事件的方式去處理。網上G了很久找到一個比較簡單的示例:view plaincopy to clipboardprint?
      <script>  
      function b(){  
       alert("我被click了!!5555~~~~~~~~~~");  
      }  
       
      function a(){  
       good.onclick=b; //注意onclick不能寫成onClick,要不沒效果的。  
      }  
       
      </script>  
      <div id="good" style="height:100px; width:100px;background:#323923;color:white;">點我啊</div>  
       
      <input type=button value="添加點擊事件" onclick="a();"> 

      <script>
      function b(){
       alert("我被click了!!5555~~~~~~~~~~");
      }

      function a(){
       good.onclick=b; //注意onclick不能寫成onClick,要不沒效果的。
      }

      </script>
      <div id="good" style="height:100px; width:100px;background:#323923;color:white;">點我啊</div>

      <input type=button value="添加點擊事件" onclick="a();">  不過在用的時候很是郁悶,如為good添加onMoserOver的事件view plaincopy to clipboardprint?
      document.getElementById('QuickUserLoginPart').onmouseover = alert("移過了!"); 

      document.getElementById('QuickUserLoginPart').onmouseover = alert("移過了!");  把這個添加在input的onClick里,點擊了馬上會彈出一個“移過了!”的提示框,然后當你鼠標移過那個ID為GOOD的區(qū)域時是什么反應都沒有的。一定要把"onmouseover ="后面的內容寫上相關定義好的function才行。  光明白這點就浪費了我兩個小時時間啊~~~~~~學藝不精啊。

      PS:不知道有沒有去除頁面元素添加事件的JS

      再記錄個:
      JS:動態(tài)添加刪除元素view plaincopy to clipboardprint?
      <HEAD>  
      <SCRIPT>  
      function removeElement()  
      {  
       try 
       {  
       //The first child of the div is the bold element.  
       var oChild=Div1.children(0);  
       Div1.removeChild(oChild);  
       }  
       catch(x)  
       {  
       alert("You have already removed the bold element. Page will be refreshed when you click OK.")  
       document.location.reload();  
       }  
      }  
      </SCRIPT>  
      </HEAD>  
      <BODY>  
      <DIV ID=Div1 onclick="removeElement()">  
      Click anywhere in this sentence to remove this <B>Bold1</B><B>Bold2</B> word.  
      </DIV>  
      </BODY> 

      <HEAD>
      <SCRIPT>
      function removeElement()
      {
       try
       {
       //The first child of the div is the bold element.
       var oChild=Div1.children(0);
       Div1.removeChild(oChild);
       }
       catch(x)
       {
       alert("You have already removed the bold element. Page will be refreshed when you click OK.")
       document.location.reload();
       }
      }
      </SCRIPT>
      </HEAD>
      <BODY>
      <DIV ID=Div1 onclick="removeElement()">
      Click anywhere in this sentence to remove this <B>Bold1</B><B>Bold2</B> word.
      </DIV>
      </BODY>再記錄個不錯的站點:

      “通過網絡汲取營養(yǎng)”——關注國外WEB相關技術,理念,使用技巧...

      關于Cookie的使用說明:

        本站是提供個人知識管理的網絡存儲空間,所有內容均由用戶發(fā)布,不代表本站觀點。請注意甄別內容中的聯系方式、誘導購買等信息,謹防詐騙。如發(fā)現有害或侵權內容,請點擊一鍵舉報。
        轉藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多