Reputation: 865
I want to change the value of an input field with jquery.
I generate the target id as follows:
var target_id = the_clicked_button.replace('_btn','');
var myValue = "sample";
I want to assign the value of myValue to target_id. Here's what I've tried out.
("#($( "target_id" ).val();)").val(myValue);
Upvotes: 0
Views: 43
Reputation: 57095
Try
$('#' + target_id).val(myValue);
// ^ String Concatenation
Upvotes: 1