function testStr(){ //var str = "China No.1"; var str = "你好,我是周杰伦!你好啊哈哈哈哈啊哈哈哈"; alert(str.substring(0,11)); }
<button onclick="testStr()">字符串测试</button>