我需要的是jQuery的獲得.VAL
($(this).attr("value"));
了「這個」價值的「本」,以顯示
$("#activities_" +btn_id).val($(this).val());
在這裏是代碼。
$('.thoughts_list').click(function(){
($(this).attr('id'));
($(this).attr("value"));
});
$('#close_thoughts').click(function(){
$("#activities_" +btn_id).val($(this).val());
});
目前,正在返回的「取消」的價值,這是「#close_thoughts」的價值,而不是我需要點擊「.thoughts列表」
的回答值,apperantly這是我正在尋找的。
$('.thoughts_list').click(function(){
($(this).attr('id'));
($(this).attr("value"));
});
$('#close_thoughts').click(function(){
$("#activities_" +btn_id).val($('input[name=thoughts_list]:checked').val());
});
但是'$( 「#activities_」 + btn_id).VAL($(本).VAL());'是'裏面$( '#close_thoughts')點擊(函數(){'處理器...你怎麼知道哪個'.thoughts_list'被點擊了? –
這可能無法解決你的問題,但這是個好主意,用this.id替換$(this).attr(「id」)。 ,'$(this).attr(「value」)'如果是'select/radio/checkbox',則使用'$(this).val()',否則使用'this.value'。 –