Home >Web Front-end >Front-end Q&A >How to convert uppercase to lowercase in jquery
Method: 1. Use toLowerCase() method, the syntax is "Characters that need to be converted to lowercase.toLowerCase()"; 2. Use toLocaleLowerCase() method, the syntax is "Characters that need to be converted to lowercase.toLocaleLowerCase()" ".
The operating environment of this tutorial: windows10 system, jquery3.2.1 version, Dell G3 computer.
1. The toLowerCase() method is used to convert a string to lowercase.
Syntax
string.toLowerCase()
The example is as follows:
<html> <head> <meta charset="utf-8"> <title>123</title> </head> <body> <script> var txt="ABCDEFGhijklmn"; document.write(txt.toLowerCase() + "<br>"); document.write(txt.toUpperCase()); </script> </body> </html>
Output result:
Expand knowledge:
The toUpperCase() method is used to convert a string to uppercase.
The syntax is:
string.toUpperCase()
2. toLocaleLowerCase() method
toLocaleLowerCase() method is based on the local host locale converts the string to lowercase.
Local is determined based on the browser's language settings.
Generally, this method returns the same result as the toLowerCase() method, only a few languages (such as Turkish) have local-specific case mapping.
The syntax is:
string.toLocaleLowerCase()
The example is as follows:
<html> <head> <meta charset="utf-8"> <title>123</title> </head> <body> <p>点击按钮将字符串转换为小写。</p> <button onclick="myFunction()">点我</button> <p id="demo"></p> <script> function myFunction() { var str = "ABCDEFGhijklmn"; var res = str.toLocaleLowerCase(); document.getElementById("demo").innerHTML = res; } </script> </body> </html>
Output result:
Expand knowledge:
The toLocaleUpperCase() method converts a string to uppercase according to the locale of the local host.
Recommended related video tutorials: jQuery video tutorial
The above is the detailed content of How to convert uppercase to lowercase in jquery. For more information, please follow other related articles on the PHP Chinese website!