Last Updated: January 28, 2019
·
972
· sensiblemnd

Ever wanted to Lowercase or Uppercase everything in certain DOM elements with jQuery?

This is how to do it. I know I could have made a plugin but im lazy right now.

$("element").each(
function(index, value) {
var textToLower = $(this).text();
$(this).text(textToLower.toLowerCase());
}
);

$("element").each(
function(index, value) {
var textToLower = $(this).text();
$(this).text(textToLower.toUpperCase());
}
);

2 Responses
Add your response

Why not just use css classes and the 'text-transform' property?

over 1 year ago ·

You could. But I wanted to do it in JS...

over 1 year ago ·

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Related Tags
#javascript
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside