0
嗨,我已经给定的代码触发器更改函数并在jquery中设置select的值?
$('#filled-in-box2').on('click', function() {
if ($('#filled-in-box2').is(':checked')) {
$('select#employee_permanent_address_attributes_country').val($('select#employee_contact_attributes_country').val()).change();
$('select#permanent_address_state_code').val($('select#contact_state_code').val());
}
});
所以我想以后更改功能或在那时只有permanent_address_state_code值将设置相同contact_state_code值改变功能触发。 我曾尝试这个代码太多,但它不工作
$('#filled-in-box2').on('click', function() {
if ($('#filled-in-box2').is(':checked')) {
$('select#employee_permanent_address_attributes_country').val($('select#employee_contact_attributes_country').val()).trigger('change',function(){
$('select#permanent_address_state_code').val($('select#contact_state_code').val());
});
}
});
我attachiing快照时,点击复选框不填充状态
请指导我如何解决这个问题。提前致谢。
小提琴请... –
这些都是选择不复选框。这就是你的代码无法工作的原因之一。 https://forum.jquery.com/topic/how-to-dynamically-select-option-in-dropdown-menu – max