Главная  /  JavaScript  /

JavaScript - События

  1. JavaScript - событие Onclick

    • по изменению Элемент HTML был изменен • по щелчку Пользователь щелкает элемент HTML • при наведении курсора на Пользователь наводит указатель мыши на элемент HTML. • onmouseout Пользователь отводит указатель мыши от элемента HTML. • onkeydown Пользователь нажимает клавишу на клавиатуре • в процессе Браузер завершил загрузку страницы W3Schools Справочник по JavaScript События HTML DOM
    <div onmouseover="mOver(this)" onmouseout="mOut(this)" style="background-color:#D94A38;width:90px;height:20px;padding:40px; color:#fff;"> Click Me</div> <script> function mOver(obj) { obj.style.backgroundColor = "#1ec5e5"; obj.innerHTML = "Release Me"; } function mOut(obj) { obj.style.backgroundColor="#D94A38"; obj.innerHTML="Thank You"; } </script>
    Click Me

    <div onmousedown="mDown(this)" onmouseup="mUp(this)" style="background-color:#D94A38;width:90px;height:20px;padding:40px; color:#fff;"> Click Me</div><script> function mDown(obj) { obj.style.backgroundColor = "#1ec5e5"; obj.innerHTML = "Release Me"; } function mUp(obj) { obj.style.backgroundColor="#D94A38"; obj.innerHTML="Thank You"; } </script>
    Click Me

    <h3 onclick="this.innerHTML='Ooops!'">Click on this text!</h3>

    Click on this text!


    <h3 onclick="changeText(this)">Click on this text!</h3> <script> function changeText(id) { id.innerHTML = "Ooops!"; } </script>

    Click on this text!


    <button onclick="document.getElementById('demo').innerHTML=Date()">The time is?</button> <div id="demo"></div>

    <button onclick="this.innerHTML=Date()">The time is?</button>
    <div>Click the button to display the date.</div> <button onclick="displayDate()">The time is?</button> <script> function displayDate() { document.getElementById("demo1").innerHTML = Date(); } </script> <div id="demo1"></div>
    Click the button to display the date.