What I need is the \"this\" value of
( $(this).attr(\"value\"));
to show up in the \"this\" of
$(\"#activities_\" +btn_id).val
This is what my boss gave me to work with.
$('.thoughts_list').click(function(){
( $(this).attr('id'));
( $(this).attr("value"));
});
$('#close_thoughts').click(function(){
$("#activities_" +btn_id).val($('input[name=thoughts_list]:checked').val());
});
This perhaps?
$('.thoughts_list').on('click', function() {
$("#activities_" + this.id).val(this.value);
});
Your question is quite cryptic. Are you trying to change the value for the element with an ID of activities_
+ the ID of the clicking element? If so, the above will work. If not, you need to elucidate your situation a bit more.
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()
.