0

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);

1 Answer 1

1

Try

$('#' + target_id).val(myValue);
//    ^ String Concatenation
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.