close
<script>
var x = "Hello I am cho, my husband ping.<br>";
document.write(x);
document.write(x.length+"<br>"); //會計算文字長度
document.write(x.big()); //字體放大
document.write(x.small()); //字體縮小
document.write(x.match("llo")+"<br>"); //找出相同字串,就秀出llo
document.write(x.match("lloo")+"<br>"); //找不出相同字串,就秀出null
document.write(x.indexOf("llo")+"<br>"); //找llo是在x變數的字串內第幾個字,結果為2,因為字串陣列從0開始算
document.write(x.replace("ping","hlb-ping")); //將cho取代ping
document.write(x.toLowerCase()); //大小寫均改成小寫
document.write(x.toUpperCase()); //大小寫均改成大寫
document.write(x.fontcolor("ff0000")); //字體為紅色
document.write(x.link("http://tw.yahoo.com")); //文字給予連結
</script>
執行結果如下
全站熱搜