富贵资源网 Design By www.hznty.com

使用循环和分割来替换和删除元素,经测试很简单,但很实用,特别适合新手朋友

<!DOCTYPE> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
<title>使用循环和分割来替换和删除元素</title> 
<script> 
var arr = new Array("ab","aa","bc","ab","ss","ab","ss","dd","ab","aa","aa","aa"); 
while(arr.indexOf("ab") != -1){ 
console.log("1"+arr); 
arr.splice(arr.indexOf("ab"),1,"**"); 
} 
console.log(arr); 
while(arr.indexOf("**") != -1){ 
console.log(arr); 
arr.splice(arr.indexOf("**"),1); 
} 
console.log(arr); 
</script> 
</head> 

<body> 
</body> 
</html>

ie8还不支持indexOf和splice

富贵资源网 Design By www.hznty.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
富贵资源网 Design By www.hznty.com