1

var k="gtype"

alert($("#forma [name=gtype]")) works but how do I use the variable k in the name selection.

4 Answers 4

3

Like this:

$("#forma [name="+k+"]");
Sign up to request clarification or add additional context in comments.

Comments

2

Simply by

alert($("#forma [name="+k+"]"));

Comments

2
alert($("#forma [name="+k+"]"))

Comments

1

You should also remember to enclose your selector string parameters into quotes, like this

alert($('#forma [name="'+k+'"]'));

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.