First letter to be capitalize Jquery

This question already has an answer here: How do I make the first letter of a string uppercase in JavaScript? 69 answers 干得好: data[0] = data[0].toUpperCase(); 使用Javascript Prototype .. String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); } var test = "hello"; console.log(test.capitalize())

首字母大写Jquery

这个问题在这里已经有了答案: 如何在JavaScript中制作字符串大写的第一个字母? 69个答案 干得好: data[0] = data[0].toUpperCase(); 使用Javascript Prototype .. String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); } var test = "hello"; console.log(test.capitalize())

CAN'T Use 'toUpperCase' (JS)

This question already has an answer here: How do I make the first letter of a string uppercase in JavaScript? 69 answers The best method I've found is just to call toUpperCase on the first character and concat the rest of the string using slice : function capitalize(str) { if(typeof str === 'string') { return str[0].toUpperCase() + str.slice(1); } return str; } If you want to

不能使用'toUpperCase'(JS)

这个问题在这里已经有了答案: 如何在JavaScript中制作字符串大写的第一个字母? 69个答案 我发现的最好的方法就是在第一个字符上调用toUpperCase ,并使用slice对字符串的其余部分进行连接: function capitalize(str) { if(typeof str === 'string') { return str[0].toUpperCase() + str.slice(1); } return str; } 如果你想在句子中大写每个单词,你可以分割空间: "capitalize each word of this sentence

First letter uppercase, the rest lower case

This question already has an answer here: How do I make the first letter of a string uppercase in JavaScript? 69 answers This is a simple script that will allow you to do this. <input type="text" id="name" onblur="capitalize(this.id)" value="" autofocus> <script> function capitalize(id) { var text = document.getElementById(id).value; //get the text var f

首字母大写,其余小写

这个问题在这里已经有了答案: 如何在JavaScript中制作字符串大写的第一个字母? 69个答案 这是一个简单的脚本,可以让你做到这一点。 <input type="text" id="name" onblur="capitalize(this.id)" value="" autofocus> <script> function capitalize(id) { var text = document.getElementById(id).value; //get the text var firstL = text.slice(0,1).toUpperCase(); //get the fi

Capitalize first letter of string on json sending

This question already has an answer here: How do I make the first letter of a string uppercase in JavaScript? 69 answers You can use following function to capitalise any string (source) function capitalizeFirstLetter(string) { return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase(); } Here, first character is changed to uppercase using string.charAt(0).toUpperCase() and r

在json发送时大写首字母的字符串

这个问题在这里已经有了答案: 如何在JavaScript中制作字符串大写的第一个字母? 69个答案 您可以使用以下函数来大写任何字符串(源) function capitalizeFirstLetter(string) { return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase(); } 在这里,使用string.charAt(0).toUpperCase()将第一个字符改为大写,其余部分改为小写。 您可以使用此功能修改您的请求,如下所示。 source: function( requ

Capitalize the first letter of sentense in JavaScript/Jquery

This question already has an answer here: How do I make the first letter of a string uppercase in JavaScript? 69 answers You don't need jQuery for this. You can use Javascript string and array functions. Split the string by . , to separate different sentences Trim each sentence Capitalize first letter Join by . var str = 'this is a test. this is one more test. and this also ne

在JavaScript / Jquery中使用首字母大写

这个问题在这里已经有了答案: 如何在JavaScript中制作字符串大写的第一个字母? 69个答案 你不需要这个jQuery。 您可以使用Javascript string和array函数。 将字符串拆分. ,分开不同的句子 修剪每个句子 首字母大写 加入. var str = 'this is a test. this is one more test. and this also new test.'; var newStr = str.split('.').map(function(el) { el = el.trim(); return el.substr(0, 1).toUp

How can I make the first letter of a variable always capital?

Possible Duplicate: Capitalize the first letter of string in JavaScript I am making something called "The HTML Quiz". It's made with JavaScript. When the user first enters it, they have to enter their name. Once they click submit, the name they enter is saved into a variable. It doesn't look nice when it says: Dear nathan, You are about to take The HTML Quiz. Please

我怎样才能让变量的首字母总是大写?

可能重复: 在JavaScript中大写字母的第一个字母 我正在做一个叫做“HTML测验”的东西。 它是用JavaScript制作的。 当用户首次输入时,他们必须输入他们的名字。 一旦他们点击提交,他们输入的名称将被保存到一个变量中。 它看起来不太好看: 亲爱的纳森, 您即将参加HTML测验。 请..... 我认为它看起来更像这样: 亲爱的纳丹, 您即将参加HTML测验。 请..... 但是如果用户以小写字母开头输入他们的名字,它

Uppercase first letter of only the first word

Possible Duplicate: Capitalize the first letter of string in JavaScript How do you force the first letter of the first word in a field to uppercase? Asked before: How do I make the first letter of a string uppercase in JavaScript? The correct answer: function capitalizeFirstLetter(string) { return string.charAt(0).toUpperCase() + string.slice(1); } You can use it like this: var myS

只有第一个单词的大写首字母

可能重复: 在JavaScript中大写字母的第一个字母 你如何强迫字段中第一个单词的第一个字母为大写? 之前问过:如何在JavaScript中创建一个字符串大写的第一个字母? 正确答案: function capitalizeFirstLetter(string) { return string.charAt(0).toUpperCase() + string.slice(1); } 你可以像这样使用它: var myString = "hello world"; alert(capitalizeFirstLetter(myString)); 它会提醒Hello world 你不

Converting First Charcter of String to Upper Case

This question already has an answer here: How do I make the first letter of a string uppercase in JavaScript? 69 answers You are almost there. Instead of uppercasing the entire string, uppercase only the first character. Array.prototype.myUcase = function() { for (var i = 0, len = this.length; i < len; i += 1) { this[i] = this[i][0].toUpperCase() + this[i].slice(1);

将字符串的第一个字符转换为大写

这个问题在这里已经有了答案: 如何在JavaScript中制作字符串大写的第一个字母? 69个答案 你几乎在那里。 而不是大写整个字符串,只大写第一个字符。 Array.prototype.myUcase = function() { for (var i = 0, len = this.length; i < len; i += 1) { this[i] = this[i][0].toUpperCase() + this[i].slice(1); } return this; } var A = ["one", "two", "three", "four"] console.log(A.my

How do I make the first letter of a string uppercase?

Possible Duplicate: Capitalize first letter of string in javascript How do I make the first letter of a string uppercase? 这是一个可以做到的功能function firstToUpperCase( str ) { return str.substr(0, 1).toUpperCase() + str.substr(1); } var str = 'hello, I'm a string'; var uc_str = firstToUpperCase( str ); console.log( uc_str ); //Hello, I'm a string

如何制作字符串大写的第一个字母?

可能重复: 在javascript中首字母大写 如何制作字符串大写的第一个字母? 这是一个可以做到的功能function firstToUpperCase( str ) { return str.substr(0, 1).toUpperCase() + str.substr(1); } var str = 'hello, I'm a string'; var uc_str = firstToUpperCase( str ); console.log( uc_str ); //Hello, I'm a string

Seeding the random number generator in Javascript

是否有可能在Javascript中播种随机数发生器(Math.random)? No, it is not, but it's fairly easy to write your own generator, or better yet use an existing one. Check out: this related question. Also, see David Bau's blog for more information on seeding. My other answer represents a more traditional algorithm, but I found Dave Scotese's comment to this answer to be a more eloquent o

在Javascript中播种随机数发生器

是否有可能在Javascript中播种随机数发生器(Math.random)? 不,它不是,但编写自己的发电机相当容易,或者更好地使用现有的发电机。 退房:这个相关的问题。 此外,请参阅David Bau的博客,了解有关播种的更多信息。 我的另一个答案代表了一个更传统的算法,但我发现Dave Scotese对这个答案的评论是一个更有说服力的评论。 不幸的是,由于字符串操作,它非常慢。 这个版本的速度要快20倍左右,而且要更精确一些。 var