问题描述
- JQ中click事件在ie上无效,火狐,谷歌,360都正常
-
$('input:radio').bind("click", function () { // alert("11"); var cs = $(this).attr('class').toString(); var a = $(this).attr('id').toString(); var c = cs.substring(0, 4); // alert("22"); if (c == "yxdk") { $('#cardNo').show(); $('#cardPwd').show(); } else { $('#cardNo').hide(); $('#cardPwd').hide(); } if (a == "dkc") { $('#option_01').addClass('card'); } else { $('#option_01').removeClass('card'); } var ck = $(this).attr('checked'); if (ck == "checked") { var id = $(this).attr('id').toString(); $("#types").val(id); } }); ------------- html代码 # <div id="sj" style=" margin-top:10px;" > <p style="color:White; padding-left: 8px;display: block;width: 96px;height: 24px;line-height: 24px;background-image: url(../../Images/pane.png);margin-bottom: 5px;margin-left: -8px;">充值卡支付</p> <input type="radio" id="zhilt" name="rtype" class="yxdk rad" value="LT"> <label name="zhilt" class="label1" for="zhilt">联通卡充值</label> <input type="radio" id="zhidx" name="rtype" class="yxdk rad" value="DX" > <label name="zhidx" class="label1" for="zhidx">电信卡充值</label> <input type="radio" id="zhisz" name="rtype" class="yxdk rad" value="SZ" > <label name="zhisz" class="label1" for="zhisz">移动卡充值</label> </div>
解决方案
ie不支持bind你换成onclick事件吧
解决方案二:
jquery倒入没有,代码要放到html代码下面或者dom ready中,还有其他的代码在哪里?cardNo,cardPwd
<div id="sj" style=" margin-top:10px;" >
<p style="color:White; padding-left: 8px;display: block;width: 96px;height: 24px;line-
height: 24px;background-image: url(../../Images/pane.png);margin-bottom: 5px;margin-left: -8px;">充值卡支付</p>
<input type="radio" id="zhilt" name="rtype" class="yxdk rad" value="LT">
<label name="zhilt" class="label1" for="zhilt">联通卡充值</label>
<input type="radio" id="zhidx" name="rtype" class="yxdk rad" value="DX" >
<label name="zhidx" class="label1" for="zhidx">电信卡充值</label>
<input type="radio" id="zhisz" name="rtype" class="yxdk rad" value="SZ" >
<label name="zhisz" class="label1" for="zhisz">移动卡充值</label>
</div>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.2.min.js"></script>
<script>
$('input:radio').bind("click", function () {
var cs = $(this).attr('class').toString();
var a = $(this).attr('id').toString();
var c = cs.substring(0, 4);
alert(cs+"|"+a+"|"+c);//////////没有问题可以输出
// alert("22");
if (c == "yxdk") {
$('#cardNo').show();
$('#cardPwd').show();
}
else {
$('#cardNo').hide();
$('#cardPwd').hide();
}
if (a == "dkc") {
$('#option_01').addClass('card');
}
else {
$('#option_01').removeClass('card');
}
var ck = $(this).attr('checked');
if (ck == "checked") {
var id = $(this).attr('id').toString();
$("#types").val(id);
}
});
</script>
时间: 2024-08-06 21:56:35