How to pass the jquery variable into the input as a attribute [duplicate]
up vote
2
down vote
favorite
This question already has an answer here:
How to use javascript variables in jquery selectors
6 answers
How to add the Jquery or Javascript variable into the input attribute. Whether it is possible or not?
var name="Jack";
$("input[type=radio][name=name]").attr('disabled', true);
javascript jquery input
marked as duplicate by Mohammad, Community♦ Nov 19 at 9:25
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
up vote
2
down vote
favorite
This question already has an answer here:
How to use javascript variables in jquery selectors
6 answers
How to add the Jquery or Javascript variable into the input attribute. Whether it is possible or not?
var name="Jack";
$("input[type=radio][name=name]").attr('disabled', true);
javascript jquery input
marked as duplicate by Mohammad, Community♦ Nov 19 at 9:25
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
1
$("input[type=radio][name="+name+"]").attr('disabled', true);
– Ramin
Nov 19 at 9:24
1
$(`input[type=radio][name=${name}]`).attr('disabled', true);
– fanjabi
Nov 19 at 9:26
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
This question already has an answer here:
How to use javascript variables in jquery selectors
6 answers
How to add the Jquery or Javascript variable into the input attribute. Whether it is possible or not?
var name="Jack";
$("input[type=radio][name=name]").attr('disabled', true);
javascript jquery input
This question already has an answer here:
How to use javascript variables in jquery selectors
6 answers
How to add the Jquery or Javascript variable into the input attribute. Whether it is possible or not?
var name="Jack";
$("input[type=radio][name=name]").attr('disabled', true);
This question already has an answer here:
How to use javascript variables in jquery selectors
6 answers
javascript jquery input
javascript jquery input
edited Nov 19 at 9:41
jnuK
1,4651325
1,4651325
asked Nov 19 at 9:20
Gowtham Koushik
617
617
marked as duplicate by Mohammad, Community♦ Nov 19 at 9:25
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Mohammad, Community♦ Nov 19 at 9:25
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
1
$("input[type=radio][name="+name+"]").attr('disabled', true);
– Ramin
Nov 19 at 9:24
1
$(`input[type=radio][name=${name}]`).attr('disabled', true);
– fanjabi
Nov 19 at 9:26
add a comment |
1
$("input[type=radio][name="+name+"]").attr('disabled', true);
– Ramin
Nov 19 at 9:24
1
$(`input[type=radio][name=${name}]`).attr('disabled', true);
– fanjabi
Nov 19 at 9:26
1
1
$("input[type=radio][name="+name+"]").attr('disabled', true);
– Ramin
Nov 19 at 9:24
$("input[type=radio][name="+name+"]").attr('disabled', true);
– Ramin
Nov 19 at 9:24
1
1
$(`input[type=radio][name=${name}]`).attr('disabled', true);
– fanjabi
Nov 19 at 9:26
$(`input[type=radio][name=${name}]`).attr('disabled', true);
– fanjabi
Nov 19 at 9:26
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
accepted
Try this
var name="Jack";
$("input[type=radio][name="+name+"]").attr('disabled', true);
add a comment |
up vote
0
down vote
You have to use quotes around your attribute selector value. Further, name=name
does not "insert" the variable's value as you intend to. You can use backticks (template literals) to do so. The following example only selects the input with name="foo" (jQuery $ does the same):
const name = "foo"
console.log(document.querySelector(`input[type="radio"][name="${name}"]`))
<input type="radio" name="foo" />
<input type="radio" name="bar" />
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Try this
var name="Jack";
$("input[type=radio][name="+name+"]").attr('disabled', true);
add a comment |
up vote
1
down vote
accepted
Try this
var name="Jack";
$("input[type=radio][name="+name+"]").attr('disabled', true);
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Try this
var name="Jack";
$("input[type=radio][name="+name+"]").attr('disabled', true);
Try this
var name="Jack";
$("input[type=radio][name="+name+"]").attr('disabled', true);
answered Nov 19 at 9:22
Kamil Kiełczewski
8,00775486
8,00775486
add a comment |
add a comment |
up vote
0
down vote
You have to use quotes around your attribute selector value. Further, name=name
does not "insert" the variable's value as you intend to. You can use backticks (template literals) to do so. The following example only selects the input with name="foo" (jQuery $ does the same):
const name = "foo"
console.log(document.querySelector(`input[type="radio"][name="${name}"]`))
<input type="radio" name="foo" />
<input type="radio" name="bar" />
add a comment |
up vote
0
down vote
You have to use quotes around your attribute selector value. Further, name=name
does not "insert" the variable's value as you intend to. You can use backticks (template literals) to do so. The following example only selects the input with name="foo" (jQuery $ does the same):
const name = "foo"
console.log(document.querySelector(`input[type="radio"][name="${name}"]`))
<input type="radio" name="foo" />
<input type="radio" name="bar" />
add a comment |
up vote
0
down vote
up vote
0
down vote
You have to use quotes around your attribute selector value. Further, name=name
does not "insert" the variable's value as you intend to. You can use backticks (template literals) to do so. The following example only selects the input with name="foo" (jQuery $ does the same):
const name = "foo"
console.log(document.querySelector(`input[type="radio"][name="${name}"]`))
<input type="radio" name="foo" />
<input type="radio" name="bar" />
You have to use quotes around your attribute selector value. Further, name=name
does not "insert" the variable's value as you intend to. You can use backticks (template literals) to do so. The following example only selects the input with name="foo" (jQuery $ does the same):
const name = "foo"
console.log(document.querySelector(`input[type="radio"][name="${name}"]`))
<input type="radio" name="foo" />
<input type="radio" name="bar" />
const name = "foo"
console.log(document.querySelector(`input[type="radio"][name="${name}"]`))
<input type="radio" name="foo" />
<input type="radio" name="bar" />
const name = "foo"
console.log(document.querySelector(`input[type="radio"][name="${name}"]`))
<input type="radio" name="foo" />
<input type="radio" name="bar" />
answered Nov 19 at 9:25
lipp
2,5381818
2,5381818
add a comment |
add a comment |
1
$("input[type=radio][name="+name+"]").attr('disabled', true);
– Ramin
Nov 19 at 9:24
1
$(`input[type=radio][name=${name}]`).attr('disabled', true);
– fanjabi
Nov 19 at 9:26