How To Underline Text In HTML Element In JavaScript? - Tutorial Kart
Maybe your like
Skip to content C++ Java PHP Python Kotlin Swift JavaScript Golang
- JavaScript
- JavaScript Tutorial
- JavaScript Comments
- JavaScript Primitive Datatypes
- JavaScript - Arithmetic Operators
- JavaScript - Comparison Operators
- JavaScript - Logical Operators
- JavaScript - If Else
- JavaScript - Switch
- JavaScript - Loops
- JavaScript - Try Catch
- JavaScript - Arrays
- JavaScript - Strings
- JavaScript - Maps
- JavaScript - Sets
- JavaScript - Classes
- JavaScript - Date
- JavaScript - Date Methods
- JavaScript in HTML Docuemnt
- JavaScript Howtos - HTML Element
- JavaScript Howtos - Paragraph
- JavaScript Howtos - Div
JavaScript – Underline Text in HTML Element
To underline text in HTML Element using JavaScript, get reference to the HTML Element element, and assign element.style.textDecoration property with value of "underline".
In the following example, we will underline the text in HTML Element with id "myElement" in JavaScript, using element.style.textDecoration property.
example.html
</> Copy <!DOCTYPE html> <html lang="en"> <head> <style> #myElement { border:1px solid #CCC; width:100px; height:100px; } </style> <meta charset="utf-8"> </head> <body> <h2>Underline text in HTML Element using JavaScript</h2> <div id="myElement">Hello World!</div> <br> <button type="button" onclick="changeStyle()">Click Me</button> <script> function changeStyle(){ var element = document.getElementById("myElement"); element.style.textDecoration = "underline"; } </script> </body> </html>Conclusion
In this JavaScript Tutorial, we learned how to underline text in a HTML Element using JavaScript.
❮ Previous Next ❯Popular Alternatives
Microsoft Office Alternatives Google Photos Alternatives What is Artificial IntelligencePopular Courses
SAP
- SAP FI
- SAP CO
- SAP HR
- SAP SD
- SAP PS
- SAP ABAP
- SAP MM
- SAP PP
- SAP PM
- SAP GRC
CRM
- Salesforce
- Salesforce Admin
- Salesforce Developer
- Visualforce
- Informatica
SAP Resources
- SAP Tables
- SAP Tcodes
Apache
- Hadoop
- Kafka Tutorial
- MXNet
- OpenNLP
- PDFBox
- Spark Tutorial
- Tomcat Tutorial
GUI
- JavaFX
- Python Tkinter
Programming
- C#
- C++
- Dart
- Golang
- Java
- Julia
- Kotlin
- Python
- R
- Scala
- Swift
- TypeScript
- MongoDB
- MySQL
- PostgreSQL
Databases
Mobile
- Android Compose
- Flutter
- Kotlin Android
- SwiftUI
Linux
- Bash Script
Web & Server
- PHP
- HTML
- CSS
- JavaScript
- NGINX
- NodeJS
Testing
- Selenium Java
Learning
- Maths
- Physics
- Chemistry
- Units
- Definitions
- Fashion
- General Knowledge
- How-To
Tag » How To Underline On Html
-
HTML Tag - GeeksforGeeks
-
HTML U Tag - W3Schools
-
How To Underline A Text In HTML? - Tutorialspoint
-
: The Unarticulated Annotation (Underline) Element - HTML
-
HTML Underline Text – How To Use The Tag With Example Code
-
How To Underline In Html - Linux Hint
-
How To Underline Text In HTML (with Pictures) - WikiHow
-
How To Underline Text In HTML
-
How To Underline Text In HTML - YouTube
-
Learn How To Underline In HTML - BitDegree
-
Underlined Text In HTML | The HTML Shark
-
How To Underline Text In CSS - Javatpoint
-
HTML Underline Tag – Understand U Tag With Examples
-
Underline Tag In HTML - Plus2net