
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
HTML DOM Event type Property
The HTML DOM Event type property returns a string corresponding to the event’s type such as click, keypress, load, or touchend.
Following is the syntax −
Returning number of seconds a transition has run −
event.type
Let us see an example of Event type property −
Example
<!DOCTYPE html> <html> <head> <title>HTML DOM Event type</title> <style> form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; } input[type="button"] { border-radius: 10px; } .playArea { display: inline-block; border-radius: 50%; background-color: #DC3545; width: 50px; height: 50px; border: 3px solid #AC3509; transition: all 1.3s ease; } .clickStyle { transform: scale(1.5); } .touchstartStyle { transform: translateX(50px); } </style> </head> <body> <form> <fieldset> <legend>HTML-DOM-Event-type</legend> <div class="playArea"></div><br> <div id="divDisplay"></div> </fieldset> </form> <script> var divDisplay = document.getElementById("divDisplay"); var playDisplay = document.getElementsByClassName("playArea")[0]; var TranslateXSelect = document.getElementById("TranslateXSelect"); var ScaleSelect = document.getElementById("ScaleSelect"); function getEventType(event) { if(event.type === 'click'){ playDisplay.classList.remove('touchstartStyle'); playDisplay.classList.add('clickStyle'); divDisplay.textContent = 'Event Fired: '+event.type; } else if(event.type === 'touchstart'){ playDisplay.classList.remove('clickStyle'); playDisplay.classList.add('touchstartStyle'); divDisplay.textContent = 'Event Fired: '+event.type; } } playDisplay.addEventListener("click", getEventType); playDisplay.addEventListener("touchstart", getEventType); </script> </body> </html>
Output
Before clicking the div element −
After clicking the div element −
After touching the div element −
- Related Articles
- HTML DOM timeStamp Event Property
- HTML DOM cancelable Event Property
- HTML DOM Ol type Property
- HTML DOM Object type Property
- HTML DOM Anchor type Property
- HTML DOM Button type Property
- HTML DOM Select type Property
- HTML DOM Link type Property
- HTML DOM Fieldset type property
- HTML DOM Input Button type Property
- HTML DOM Input FileUpload type Property
- HTML DOM Input Hidden type Property
- HTML DOM Input Month type Property
- HTML DOM Input Password type property
- HTML DOM Input Radio type property

Advertisements