toUpperCase() 方法用于把字符串转换为大写。
一个新的字符串,在其中 stringObject 的所有小写字符全部被转换为了大写字符。
语法为:stringObject.toUpperCase()实例
在本例中,"Hello world!" 将以大写字母来显示:
var str="Hello World!"
document.write(str.toUpperCase())
效果如下:
相关方法举例如下:
var txt="Hello World!"
document.write("
Big: " + txt.big() + "
")document.write("
Small: " + txt.small() + "
")document.write("
Bold: " + txt.bold() + "
")document.write("
Italic: " + txt.italics() + "
")document.write("
Blink: " + txt.blink() + " (does not work in IE)
")document.write("
Fixed: " + txt.fixed() + "
")document.write("
Strike: " + txt.strike() + "
")document.write("
Fontcolor: " + txt.fontcolor("Red") + "
")document.write("
Fontsize: " + txt.fontsize(16) + "
")document.write("
Lowercase: " + txt.toLowerCase() + "
")document.write("
Uppercase: " + txt.toUpperCase() + "
")document.write("
Subscript: " + txt.sub() + "
")document.write("
Superscript: " + txt.sup() + "
")document.write("
Link: " + txt.link(https://www.jb51.net) + "
")效果如下:
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。