<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script language="javascript">
$().ready(function(){
$(".xxx ul > li").each(function(){
var temp=$(this);
var tem=temp.text();
alert(tem=="测试啊");
});
});
</script>
</head>
<body>
<div class="xxx">
<ul>
<li><a href="#">测试啊</a></li>
<li><a href="#">测试啊2</a></li>
<li><a href="#">测试啊3</a></li>
<li><a href="#">测试啊4</a></li>
</ul>
</div>
</body>
</html>
开始测试IE浏览器下像你所说的那样,但是到了firefox就ok.
开始以为jquery的bug,换了新版本还是有问题.终于,我被你折磨死了.
因为你的html文件不标准.HOHO~~~,改成下面,测试通过.
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns
="http://www.w3.org/1999/xhtml">
<
head
>
<title></title
>
<script src="Styles/jquery-1.5.2.min.js" type="text/javascript"></script
>
<
script language
="javascript">
$().ready(
function
() {
$(
".xxx ul > li").each(function
() {
var temp = $(this
);
var
tem = temp.text();
alert(tem ==
"测试啊"
);
}); });
</
script
>
</
script
>
</
head
>
<
body
>
<div class
="xxx">
<ul
>
<li><a href="#">测试啊</a></li
>
<li><a href="#">测试啊2</a></li
>
<li><a href="#">测试啊3</a></li
>
<li><a href="#">测试啊4</a></li
>
</ul
>
</div
>
</
body
>
</
html
>