DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)title>
head>
<body><script>
var carname1="Volvo XC60";
var carname2='Volvo XC60';
var answer1='It's alright';
var answer2="He is called "Johnny"";
var answer3='He is called "Johnny"';
document.write(carname1 + "
")
document.write(carname2 + "
")
document.write(answer1 + "
")
document.write(answer2 + "
")
document.write(answer3 + "
")
script>body>
html>
DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)title>
head>
<body><script>
var txt = "Hello World!";
document.write("" + txt.length + "");
var txt="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
document.write("" + txt.length + "");
script>body>
html>
DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)title>
head>
<body><p id="p1">Click the button to locate where "locate" first occurs.p>
<p id="p2">0p>
<button onclick="myFunction()">点我button>
<script>
function myFunction(){var str=document.getElementById("p1").innerHTML;var n=str.indexOf("locate");document.getElementById("p2").innerHTML=n+1;
}
script>body>
html>
DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)title>
head>
<body><script>
var str="Hello world!";
document.write(str.match("world") + "
");
document.write(str.match("World") + "
");
document.write(str.match("world!"));
script>body>
html>
DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)title>
head>
<body><p>替换 "Microsoft" 为 "Runoob" :p>
<button onclick="myFunction()">点我button>
<p id="demo">请访问 Microsoft!p>
<script>
function myFunction() {var str = document.getElementById("demo").innerHTML; var txt = str.replace("Microsoft","Runoob");document.getElementById("demo").innerHTML = txt;
}
script>body>
html>
DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)title>
head>
<body><p id="demo">单击按钮显示数组。p>
<button onclick="myFunction()">点我button>
<script>
function myFunction(){var str="a,b,c,d,e,f";var n=str.split(",");document.getElementById("demo").innerHTML=n[0];
}
script>body>
html>