[RESOLVED]How do I get the first character of a string with Jquery and then change it to upper case or lower case?

How do I change the case of the fist variable of a string with Jquery

var strTest = "txtHome"

how do I change it to "TxtHome"?

If you need to handle this using jQuery or Javascript, you could just use the toUpperCase() function along with the slice() function :

// Your original string
var strTest = "txtHome";

// Capitalize it
var capitalized = strTest[0].toUpperCase() + strTest.slice(1);

You can see a working example of this here.


Leave a Reply