Blogger Information
Blog 38
fans 0
comment 3
visits 43719
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
js--字符串操作函数
意外的博客
Original
788 people have browsed it
<!DOCTYPE html>
<html>
<head>
	<title>字符串操作函数</title>
	<mate charest="utf-8">	<!-- 设置编码格式,以免乱码; -->
		<script type="text/javascript">
		
			var text='hello worid i like you';
			// length:计算字符串长度;
				// document.write(text.length);
			// charAt(数字):返回指定索引位置的字符。
				// document.write(text.charAt(0));
			//indexOf();获取子字符串索引开始位置;
				// document.write(text.indexOf('i'))
			//lastIndexOf();指出最后一个子字符串开始的位置;
				// document.write(text.lastIndexOf('k'))
			// substring(开始,结束);返回一个子字符串;
				// document.write(text.substring(2,3));
			// substr(开始,长度);返回一个子字符串;
				// document.write(text.substr(2,3));
			// replace('要的字被替换符串','替换成的字符串');
				// document.write(text.replace('you','php中文网'));	
			// concat();连接两个或多个字符串;
				// var a='你的名字'	;
				// var b='luxiansheng';
				// 	document.write(text.concat(' ',a,' ',b));
				
		</script>
</head>
<body>

</body>
</html>


<!-- length:计算字符串长度; -->
<!-- charAt(数字):返回指定索引位置的字符。 -->

总结:

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post