xxxxxxxxxx
<!DOCTYPE html>
<html>
<title>JavaScript substring() 方法 - 基础教程(div.cn)</title>
<body>
<h1>JavaScript substring() 方法</h1>
<p>点击按钮从位置4到9(10-1)提取部分字符串:</p>
<button onclick="myFunc()">Click</button>
<p id="x"></p>
<script>
function myFunc() {
var str1 = 'Air Pollution is introduction of chemicals to the atmosphere.';
var str2 = str1.substring(4, 10);
document.getElementById('x').innerHTML = str2;
}
</script>
</body>
</html>