【发布时间】:2023-03-28 22:15:02
【问题描述】:
此代码基于单击激活隐藏单选按钮的图像。注册数据库的答案, 但是它在除 Internet Explorer 之外的所有浏览器上都可以正常工作。任何建议都会被采纳
main : function(){
var thisoptions = this.options;
// Set up page:
// Add grey borders
$("input:radio").each (function () {
var spanId = "imageBox_"+$(this).attr("id");
$("#"+spanId).addClass('greyBorder');
})
// Pre-set already checked boxes with the highlight class
$("input:radio:checked").each(function () {
var spanId = "imageBox_"+$(this).attr("id");
$("#"+spanId).removeClass('greyBorder');
$("#"+spanId).addClass('imgChecked');
})
// Highlight image when clicked
$(".imageBox_"+thisoptions.q_id).click(function(){
$(".imageBox").removeClass('imgChecked');
$(".imageBox").addClass('greyBorder');
$(this).removeClass('greyBorder');
$(this).addClass('imgChecked');
});
// Highlight image when textbox used
$("input[type='text']").focus(function(){
var spanId = "imageBox_"+ $(this).attr('data-for');
$(".imageBox").removeClass('imgChecked');
$(".imageBox").addClass('greyBorder');
$("#"+spanId).removeClass('greyBorder');
$("#"+spanId).addClass('imgChecked');
});
}
};
在 Internet Explorer 中,当我按下图像时,所有边框颜色都会发生变化,并且一切看起来都已被选中,但未选中隐藏的单选按钮。即使它在所有其他浏览器中都能正常工作!
【问题讨论】:
标签: jquery html css internet-explorer