JavaScript toUpperCase()方法使用详解

网络编程 发布日期:2024/10/3 浏览次数:1

正在浏览:JavaScript toUpperCase()方法使用详解

toUpperCase() 方法用于把字符串转换为大写。 

一个新的字符串,在其中 stringObject 的所有小写字符全部被转换为了大写字符。

语法为:stringObject.toUpperCase()
实例 

在本例中,"Hello world!" 将以大写字母来显示: 

<script type="text/javascript">
var str="Hello World!"
document.write(str.toUpperCase())

</script>

效果如下: 

JavaScript toUpperCase()方法使用详解

相关方法举例如下: 

<html>
<body>

<script type="text/javascript">

var txt="Hello World!"

document.write("<p>Big: " + txt.big() + "</p>")
document.write("<p>Small: " + txt.small() + "</p>")

document.write("<p>Bold: " + txt.bold() + "</p>")
document.write("<p>Italic: " + txt.italics() + "</p>")

document.write("<p>Blink: " + txt.blink() + " (does not work in IE)</p>")
document.write("<p>Fixed: " + txt.fixed() + "</p>")
document.write("<p>Strike: " + txt.strike() + "</p>")

document.write("<p>Fontcolor: " + txt.fontcolor("Red") + "</p>")
document.write("<p>Fontsize: " + txt.fontsize(16) + "</p>")

document.write("<p>Lowercase: " + txt.toLowerCase() + "</p>")
document.write("<p>Uppercase: " + txt.toUpperCase() + "</p>")

document.write("<p>Subscript: " + txt.sub() + "</p>")
document.write("<p>Superscript: " + txt.sup() + "</p>")

document.write("<p>Link: " + txt.link(https://www.jb51.net) + "</p>")
</script>

</body>
</html> 

效果如下:

JavaScript toUpperCase()方法使用详解

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。

高通与谷歌联手!首款骁龙PC优化Chrome浏览器发布
高通和谷歌日前宣布,推出首次面向搭载骁龙的Windows PC的优化版Chrome浏览器。
在对骁龙X Elite参考设计的初步测试中,全新的Chrome浏览器在Speedometer 2.1基准测试中实现了显著的性能提升。
预计在2024年年中之前,搭载骁龙X Elite计算平台的PC将面世。该浏览器的提前问世,有助于骁龙PC问世就获得满血表现。
谷歌高级副总裁Hiroshi Lockheimer表示,此次与高通的合作将有助于确保Chrome用户在当前ARM兼容的PC上获得最佳的浏览体验。