Jquery get .val

后端 未结 3 728
暗喜
暗喜 2021-01-26 13:22

What I need is the \"this\" value of

( $(this).attr(\"value\")); 

to show up in the \"this\" of

$(\"#activities_\" +btn_id).val         


        
3条回答
  •  别那么骄傲
    2021-01-26 14:09

    If you want to get the value of the .thoughts_list element when you click the #close_thoughts element you'll need this:

    $('#close_thoughts').click(function(){
        $("#activities_" + btn_id).val($('.thoughts_list').val());   
    });
    

    Your code was setup as follows:

    $('#close_thoughts').click(function(){
        $("#activities_" +btn_id).val($(this).val());   
    });
    

    The problem here is that on the 2nd line $(this).val() is the same as $('#close_thoughts').val() and you're looking for $('.thoughts_list').val().

提交回复
热议问题