4
嗨,我需要一点jQuery的帮助,我重命名下拉列表旁边的复选框被点击。我想在下面的代码中获取名为'Prev'的下拉列表中的选定值,并将其分配给点击的复选框。我希望这是有道理的。谢谢jquery小问题我需要帮助
$('.mutuallyexclusive').live("click", function() {
checkedState = $(this).attr('checked');
$('.mutuallyexclusive:checked').each(function() {
$(this).attr('checked', false);
$(this).attr('name', 'chk');
});
$(this).attr('checked', checkedState);
if (checkedState) {
jQuery('#myForm select[name=cat.parent_id]').attr('name', 'bar')
// here is the bit i need help with
// get the selected option of the dropdown prev and set it to $(this).val.. something along those lines
var prev = $(this).prev('select').attr("name", 'cat.parent_id');
}
else {
var prev = $(this).prev('select').attr("name", 'dd');
}
});
});
你有你正在使用的表单项的HTML标记吗? – EvilChookie 2010-05-20 23:26:01
我很难理解你想要做什么。获取选定选项$(“select option:selected”)的值。val(); – 2010-05-20 23:30:25
是,从选择列表'var Prev'并将该值设置为已选中的复选框 – Martin 2010-05-20 23:52:03