<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>javascript实例</title>
<script src="jquery-1.4.2.js" type="text/javascript"></script>
<script type="text/javascript">
方法一:
function removeWithoutCopy(arr, item) {
for(var i=0;i<arr.length;i++)
{
if(arr[i]==item)
{
arr.splice(i,1);
i=0;
}
}
return arr;
}
方法2:
function removeWithoutCopy(arr, item) {
for(var i=arr.length;i>=0;i--)
{
if(arr[i]==item)
{
arr.splice(i,1);
}
}
return arr;
}
alert(removeWithoutCopy([1,2,4,3, 2,8], 2));
</script>
</head>
<body>
</body>
</html>