很奇怪的现象 jquery IE!=ff/opera/gc
由于这里图片不方便:请链接到http://tieba.baidu.com/p/1877423882看图。
[code=JScript][/code]<html>
<head>
<title>测试</title>
<script type="text/javascript" src="./js/jquery-1.7.2.js"></script>
</head>
<body>
<div>
<table border="1" id="f_delete">
<tr>
<th>场</th>
<th>赛事</th>
<th>开赛时间</th>
<th>截止时间</th>
<th>主队</th>
<th>比分</th>
<th>客队</th>
<th>主胜</th>
<th>平局</th>
<th>客胜</th>
</tr>
<tr>
<td>002</td>
<td>英甲</td>
<td>02:45</td>
<td>截止</td>
<td>莱顿东方</td>
<td>--</td>
<td>布伦特福德</td>
<td><label class="foot"><input type="checkbox" class="7"/>1.20</label></td>
<td><label class="foot"><input type="checkbox" class="8"/>1.20</label></td>
<td><label class="foot"><input type="checkbox" class="9"/>1.20</label></td>
</tr>
<tr>
<td>003</td>
<td>巴西甲</td>
<td>08:00</td>
<td>截止</td>
<td>布塔福戈</td>
<td>--</td>
<td>巴西国际</td>
<td><label class="foot"><input class="7" type="checkbox"/>2.10</label></td>
<td><label class="foot"><input class="8" type="checkbox"/>3.10</label></td>
<td><label class="foot"><input class="9" type="checkbox"/>3.30</label></td>
</tr>
<tr>
<td>004</td>
<td>巴西甲</td>
<td>08:00</td>
<td>截止</td>
<td>格雷米奥</td>
<td>--</td>
<td>累西方航海</td>
<td><label class="foot"><input class="7" type="checkbox"/>1.83</label></td>
<td><label class="foot"><input class="8" type="checkbox"/>3.55</label></td>
<td><label class="foot"><input class="9" type="checkbox"/>3.35</label></td>
</tr>
</table>
</div>
<div id="comeon">
<table border="1" id="down_table">
<tr id="tr" id="new">
<th>编号</th>
<th>主队</th>
<th>客队</th>
<th>投注卡</th>
</tr>
</table>
<form name="form_nouse">
<input type="text" id="number" name="how_much"></input>
</form>
<a id="display" style="text-decoration:none;" href="3.php?data=">确定投注</a>
</div>
<script type="text/javascript">
//定义一个array,来存放数据和作为删除增加的判断。
var newarray = new Array();
var y_attr = new Array();
//---------------------这是点击label事件--------------------------------
$('.foot').click(function(event){
if(event.target.type=="checkbox"){//event.target.type==有两个值
//用原table的x,y坐标来绝对定位id。以便后面删除。---开始
//$(this).parent().parent().children().length=10;--tr;$(this).parent().parent().children().length=4;--table
var x=$(this).parent().index();
var y=$(this).parent().parent().index();
var only=y+""+x;
//用原table的x,y坐标来绝对定位id。以便后面删除。---结束
var fu=$(this).text();
var s=$(this).parent().parent().children();
var fu1 =$(this).parent().parent().children().eq(0).text();
var fu2 = $(this).parent().parent().children().eq(4).text();
var fu3 =$(this).parent().parent().children().eq(6).text();
if($(this).children().attr("class")=="7"){
var fu4 = $(this).parent().parent().parent().children().children().eq(7).text();
}else if($(this).children().attr("class")=="8"){
var fu4 = $(this).parent().parent().parent().children().children().eq(8).text();
}else{
var fu4 = $(this).parent().parent().parent().children().children().eq(9).text();
}
var a=fu1+"_"+fu2+"_"+fu3+"_"+fu4+"_"+fu;
//点击时,颜色变黄;如果已经是黄色,则说明数组中一定有这个值。
if(typeof($(this).parent().attr("style"))=="undefined"){
$(this).parent().attr("style","background-color:#FACE0C");
newarray.push(a);
if($("#"+y).length>0){//有这一行的
$("#"+y).children().eq(3).children().eq(0).after("<span style='background-color:yellow;border:1px solid red;' id="+only+">"+fu4+"</span>");
}else{ //没有这一行的
$("#tr").after("<tr id="+y+"><td>"+fu1+"</td><td>"+fu2+"</td><td>"+fu3+"</td><td><span style='background-color:yellow;border:1px solid red;' id="+only+">"+fu4+"</span></td></tr>");
}
}else{
$(this).parent().attr("style","");
newarray.splice($.inArray(a,newarray),1);//存在就从数组中删除
if($("#"+only).parent().children().length>1){
$("#"+only).remove();
}else{
$("#"+y).detach();
}
}
//用分割法截取设置导航页面的data值
$("#display").attr("href",$("#display").attr("href").split("=")[0]+"="+newarray);
}
})
//------------------------这是点击a标签:id=display触发的事--------------------
$("#display").click(function(event){
var num=document.form_nouse.how_much.value;
var array_split=$("#display").attr("href").split("=");
$("#display").attr("href",array_split[0]+"="+newarray+"&num="+num);
});
//--------------------------------------------------------------------------
</script>
</body>
</html>
在IE浏览器下多次相同的操作都没问题,但其他3个浏览器只能操作一次,后面再点击就没效果了。怎么解决,是代码有问题还是怎么样?
[解决办法]
if(typeof($(this).parent().attr("style"))=="undefined")
改成
if(typeof($(this).parent().attr("style"))=="undefined" || $(this).parent().attr("style")=='')
这js写得....太麻烦了...