Detailed explanation of JS registration event examples

小云云
Release: 2023-03-21 14:30:01
Original
1530 people have browsed it

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>
Copy after login

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!

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!