Jquery 检查页面加载时是否选中了iCheck单选按钮
我正在使用Fronteed的iCheck插件。此代码仅在单选按钮更改时有效。但是,我还需要它来处理页面加载(我已经从数据库中提取了值,以获得当前选中的按钮)。这是我的密码:Jquery 检查页面加载时是否选中了iCheck单选按钮,jquery,icheck,Jquery,Icheck,我正在使用Fronteed的iCheck插件。此代码仅在单选按钮更改时有效。但是,我还需要它来处理页面加载(我已经从数据库中提取了值,以获得当前选中的按钮)。这是我的密码: $('input').on('ifChecked', function () { var number = this.attributes['name'].value.slice(-1); if ($(this).attr("id") == "icon") { $('#box_co
$('input').on('ifChecked', function () {
var number = this.attributes['name'].value.slice(-1);
if ($(this).attr("id") == "icon")
{
$('#box_colour_' + number).show();
$("#text_box_colour_" + number).show();
$('#text_box_' + number).show();
$('#box_icon_' + number).show();
$('#box_link_' + number).show();
$('#box_image_' + number).hide();
$('#box_video_' + number).hide();
}
});
谢谢您应该使用jQuery触发器并设置一个确定的执行时间。
你可以试试这个:
$("document").ready(function() {
setTimeout(function() {
$("input").trigger('ifChecked');
},10);
});
调用完所有$(document).ready()处理程序后,10毫秒的延迟将导致函数立即运行
原始答案:我刚刚做了一些更改。您可以在document ready-$(document).ready(function(){}上调用相同的函数。您是否尝试过:$('input')。是否(':checked')?