Home  >  Article  >  Backend Development  >  Detailed explanation of JS registration event examples

Detailed explanation of JS registration event examples

小云云
小云云Original
2018-03-15 15:31:391491browse

This article mainly shares with you the detailed explanation of JS registration event examples, hoping to help everyone.

<html xmlns="http://www.w3.org/1999/xhtml"><head>    
<title></title>    <script type="text/javascript">        
//要操作页面的元素(标签)那就要写到onload中,
    //不操作可以不用     
        function f1() {            
        alert(&#39;迁徙猿有很多猿&#39;);        
        }        onload = function () 
        {        //在html中注册事件加(),在这写不加            
        document.getElementById(&#39;btn&#39;).onclick = f1; 注册事件        };   
        </script></head><body>    <input type="button" name="name" value="神奇的按钮" id="btn" />    
        <!-- onclick="f1();"-->执行代码</body></html>

Related recommendations:

Common methods about js registration events_javascript skills

The above is the detailed content of Detailed explanation of JS registration event examples. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn