我想做一些有点尴尬的事情,我的伪代码不起作用,但应该解释我想要做什么。我有 4 个单选按钮组,在 6 个单独的 div 中,所以总共有 24 个单选按钮。每个 div 都是特定的背景颜色。When a radio button within a particular div is selected, I need to grab the colour of the div the selected radio button is within, and have it stored in a variable ready to apply it to an element that'll be created next...
$("#voucher_selection_container input:radio").change(function(){
//var color = $(this).parent("div").css("background-color");
//alert(color);
$("#voucher_customisation_container").slideDown(600);
//$("#voucher_customisation_container .voucher_box").css("background-color", color);
});
任何帮助,将不胜感激。:) 谢谢。