Javascript examples for DOM Event:onclick
The onclick event occurs when the user clicks on an element.
Bubbles | Yes |
---|---|
Cancelable | Yes |
Event type: | MouseEvent |
Supported HTML tags: | All HTML elements, EXCEPT: <base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, and <title> |
<!DOCTYPE html> <html> <body> <p>Click the button to display the time.</p> <button onclick="getElementById('demo').innerHTML=Date()">What is the time?</button> <p id="demo"></p> </body>/* w w w . jav a 2s . co m*/ </html>