这里正在使用 jquery 复选框单击功能,如果我单击 IE 9 中的复选框, if ($(this).is(':checked'))
它不会抛出警报消息..但它在 IE 10、firefox 和 chrome 中工作
if (isChildAvail == "true")
{
$(this).change(function() {
if ($(this).is(':checked')) {
alert("test");
$(this).parent().parent().append('<div id="divedit" class="editdiv"><p id="p_childlabel" class="childlabel">Children : ' + ChilAvailCount + ' </P><a class="childlabeledit">Edit</a></div>');
$('.editdiv a').click(function() {
$(this).parent().parent().append($("#divchildcontrol"));
EditForPullups();
});
}
}
有什么建议吗??
编辑:
$(this).change(function() {
问题在于更改功能而不是这个if ($(this).is(':checked'))
编辑(2):
var strCheck = "";
$('.consumer-communication-checkbox').each(function () {
strCheck = $(this).parent().text();
if (strCheck.toLowerCase().indexOf("hugg") >= 0) {
//scenario without child
if (isChildAvail == "false") {
jQuery(':checkbox').change(function () {
if ($(this).prop('checked') === true) {
$(this).parent().parent().append($("#divchildcontrol"));
IsChildcontrolwithH = "1";
IsChildcontrolwithG = "0";
IsChildcontrolwithP = "0";
} else {
if (IsChildcontrolwithH == "1") {
$("#divpersonalrightheader").append($("#divchildcontrol"));
}
}
});
}
//scenario with child
else {
if ($(this).prop('checked') === true) {
//Set SubscribedCode
SubscribedCode = "H";
$(this).parent().parent().append('<div id="divedit" class="editdiv"><p id="p_childlabel" class="childlabel">Children : ' + ChilAvailCount + ' </P><a class="childlabeledit">Edit</a></div>');
$('.editdiv a').click(function () {
$(this).parent().parent().append($("#divchildcontrol"));
EditForH();
});
}
jQuery(':checkbox').change(function () {
if ($(this).prop('checked') === true) {
$(this).parent().parent().append('<div id="divedit" class="editdiv"><p id="p_childlabel" class="childlabel">Children : ' + ChilAvailCount + ' </P><a class="childlabeledit">Edit</a></div>');
$('.editdiv a').click(function () {
$(this).parent().parent().append($("#divchildcontrol"));
EditForH();
});
} else {
$("#divedit").remove();
if (IsChildcontrolwithH == "1") {
$("#divpersonalrightheader").append($("#divchildcontrol"));
IsChildcontrolwithH = "0";
IsChildcontrolwithG = "0";
IsChildcontrolwithP = "0";
}
}
});
}
}
编辑(3):HTML内容
<div class="consumer-checkbox-wrap checked">
<label class="consumer-communication-label checkbox" for="communication_11">
<input name="communication_11" class="consumer-communication-checkbox checkbox" id="communication_11"
type="checkbox" checked="checked" value="true"><img src="Images/PMURP_Logos/hugg.jpg">
s
<p>
Please send me communications, savings, and special offers from hugg® Communications
</p>
</label>
<input name="communication_11" type="hidden" value="false"><a href="http://www.hugg.com/email/12162011/SampleNewsletter.html"
target="_blank"><img src="../kcsso/images/Newsletter/hugg.jpg"></a>
</div>
<div class="consumer-checkbox-wrap">
<label class="consumer-communication-label checkbox" for="communication_13">
<input name="communication_13" class="consumer-communication-checkbox checkbox" id="communication_13"
type="checkbox" value="true"><img src="Images/PMURP_Logos/scott.jpg">
<p>
Please send me communications, savings, and special offers from scott® Communications</p>
</label>
<input name="communication_13" type="hidden" value="false"><a href="http://www.scott.com/email/11042011/samplenewsletter.html"
target="_blank"><img src="../kcsso/images/Newsletter/scott.jpg"></a>
</div>