我单击单选按钮时成功执行更改,但问题是,当我重新加载页面时,单选按钮选择被保留,但更改不是。换句话说,如果我点击单选按钮#1,它将降低某些字段的不透明度。当我回到这个页面时,所有的字段都是完全不透明的,直到我再次单击单选按钮,它才会执行这个机会。jQuery输入触发器实时更改
这里是我的代码:
(function($) {
// Document Ready
$(document).ready(function() {
// trigger change on the radio list to show selected field
$('#acf-feature_slide ul.radio_list li label input').trigger('change');
});
// Content Type change
$('#acf-feature_slide ul.radio_list li label input').live('change', function() {
// vars
var value = $(this).val();
// show the selected field
if(value == "internal") {
$(this).parentsUntil('tr').find('div.row-layout-field').eq(3).css('opacity', '1.0');
$(this).parentsUntil('tr').find('div.row-layout-field').eq(4).css('opacity', '0.2');
}
else if(value == "external") {
$(this).parentsUntil('tr').find('div.row-layout-field').eq(3).css('opacity', '0.2');
$(this).parentsUntil('tr').find('div.row-layout-field').eq(4).css('opacity', '1.0');
}
else if(value == "none") {
$(this).parentsUntil('tr').find('div.row-layout-field').eq(3).css('opacity', '0.2');
$(this).parentsUntil('tr').find('div.row-layout-field').eq(4).css('opacity', '0.2');
}
else {
$(this).parentsUntil('tr').find('div.row-layout-field').eq(3).css('opacity', '1.0');
$(this).parentsUntil('tr').find('div.row-layout-field').eq(4).css('opacity', '1.0');
}
});
})(jQuery);
任何帮助是极大的赞赏。
感谢,
考虑使用'on'作为'live'在jQuery v1.7中被弃用了。 http://api.jquery.com/on/ – yoshi
你以哪种方式重新加载页面?它是一个“快速刷新”(通常热键“F5”),或者你也随着它清理缓存('shift + F5')。在开发过程中,我推荐后者。 – yoshi