zoukankan      html  css  js  c++  java
  • HTML DOM

    HTML DOM 允许 JavaScript 对 HTML 事件作出反应。。

    使用 HTML DOM 来分配事件

    HTML DOM 允许您使用 JavaScript 向 HTML 元素分配事件:

    实例

    为 button 元素分配 onclick 事件:

    <!DOCTYPE html>
    <html>
    <head>
    </head>
    <body>




    <button id="myBtn">试一试</button>


    <script>
    document.getElementById("myBtn").onclick=function(){
    displayDate()
    };
    function displayDate()
    {
    document.getElementById("demo").innerHTML=Date();
    }
    </script>


    <p id="demo"></p>


    </body>
    </html>


    <!DOCTYPE html>
    <html>
    <head>
    </head>
    <body>


    <p>点击按钮来执行 <b>displayDate()</b> 函数。</p>


    <button id="myBtn">试一试</button>


    <script>
    document.getElementById("myBtn").onclick=function(){displayDate()};
    function displayDate()
    {
    document.getElementById("demo").innerHTML=Date();
    }
    </script>


    <p id="demo"></p>


    </body>
    </html>


    http://www.w3school.com.cn/htmldom/dom_events.asp

  • 相关阅读:
    指针数组、数组指针以及二维数组
    jquery的基本动画方法
    jquery面试需要看的基本东西
    bootstrap
    node全栈工程师
    setTimeout 0秒
    随便写的
    Bootstrap2和3的区别
    记忆的代码
    offsetWidth与scrollLeft
  • 原文地址:https://www.cnblogs.com/baiduligang/p/4247654.html
Copyright © 2011-2022 走看看