About 1,370,000 results
Open links in new tab
  1. How do I make the first letter of a string uppercase in JavaScript ...

    Jun 22, 2009 · It's always better to handle these kinds of stuff using CSS first, in general, if you can solve something using CSS, go for that first, then try JavaScript to solve your problems, so in this case try using :first-letter in CSS and apply text-transform:capitalize;

  2. javascript - Capitalize words in string - Stack Overflow

    The answer provided by vsync works as long as you don't have accented letters in the input string.. I don't know the reason, but apparently the \b in regexp matches also accented letters (tested on IE8 and Chrome), so a string like "località" would be wrongly capitalized converted into "LocalitÀ" (the à letter gets capitalized cause the regexp thinks it's a word boundary)

  3. How can I capitalize the first letter of each word in a string using ...

    // Note that underscore _ is part of the RegEx \w+ first_char_to_uppercase( "Capitalize First Letter of each word in a String - JavaScript" ); // "Capitalize First Letter Of Each Word In A String - JavaScript" Edit 2019-02-07: If you want actual Titlecase (i.e. only the first letter uppercase all others lowercase):

  4. javascript - Capitalize the first letter of every word - Stack Overflow

    Jan 23, 2013 · If you don't mind using a library, you could use Sugar.js capitalize() capitalize( all = false ) Capitalizes the first character in the string and downcases all other letters. If all is true, all words in the string will be capitalized. Example: 'hello kitty'.capitalize() -> 'Hello kitty' 'hello kitty'.capitalize(true) -> 'Hello Kitty'

  5. javascript - How to capitalize first letter and lowercase the rest of ...

    Aug 20, 2020 · I am trying to capitalize the first letter of only the first word in a sentence. This is the data in the tsx file { this.text({ id: downloadPriceHistory, defaultMessage: 'Download Price History' }...

  6. Capitalize first letter of each word in JS - Stack Overflow

    Mar 13, 2017 · Here is a quick code snippet. This code snippet will allow you to capitalize the first letter of a string using JavaScript. function capitlizeText(word) { return word.charAt(0).toUpperCase() + word.slice(1); }

  7. javascript - How to capitalize first letter of each word, like a 2 …

    Feb 3, 2011 · capitalizedString = someString.toLowerCase().capitalize(); Also, this would work on multiple words string. To make sure the converted City name is injected into the database, lowercased and first letter capitalized, then you would need to use JavaScript before you send it over to server side.

  8. javascript - How do I make the first letter of a string uppercase ...

    May 4, 2011 · Possible Duplicate: Capitalize first letter of string in javascript How do I make the first letter of a string uppercase?

  9. javascript - Uppercase first letter of variable - Stack Overflow

    Oct 10, 2022 · To do this, you don't really even need JavaScript if you're going to use $('#test').css('text-transform', 'capitalize'); Do this as CSS like: #test,h1,h2,h3 { text-transform: capitalize; } Or do it as a class and apply that class to wherever you need it:.ucwords { text-transform: capitalize; }

  10. Capitalization convention for JavaScript objects - Stack Overflow

    Jul 12, 2016 · In a language like Java, it's a convention to begin classes with capital letters, and objects with lowercase letters. But what about JavaScript, where everything is an object? I've seen some people suggest capitalizing only objects that are treated as classes; i.e. function objects with a prototype, that are intended to be used with the new ...

Refresh