<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title></title>
</head>
<body>
<p id="f">我们都是好孩子</p>
<p id="m">你们都是好孩子</p>
<p id="n">他们都是好孩子</p>
<script type="text/javascript" src="jquery-1.7.js"></script>
<script type="text/javascript">
$("p").each(function(item,itemValue){ itemValue.css("color","red"); // 错误 itemValue.style.color="red"; // 正确 itemValue所代表的每一项,居然又变回js原生对象,为哪般
})
</script>
</body>
</html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title></title>
</head>
<body>
<p id="f">我们都是好孩子</p>
<p id="m">你们都是好孩子</p>
<p id="n">他们都是好孩子</p>
<script type="text/javascript" src="jquery-1.7.js"></script>
<script type="text/javascript">
$("p").each(function(item,itemValue){ itemValue.css("color","red"); // 错误 itemValue.style.color="red"; // 正确 itemValue所代表的每一项,居然又变回js原生对象,为哪般
})
</script>
</body>
</html>
$(itemValue).css("color","red");
就行
each里本来就是原生
然后用$( )或者jQuery进行二次转换。