Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to set the capitalization of a text with JavaScript?
To set the capitalization, use the textTransform property in JavaScript. Set it to capitalize, if you want the first letter of every word to be a capital letter.
Example
You can try to run the following code to return the capitalization of a text with JavaScript −
<!DOCTYPE html>
<html>
<body>
<button onclick = "display()">Capitalize Text</button>
<div id = "myID">
This is demo text! This is demo text!
</div>
<script>
function display() {
document.getElementById("myID").style.textTransform = "capitalize";
}
</script>
</body>
</html>Advertisements