I have the following input on my page:
<input type="text" name="r1" />
I am trying to select it with JQuery, using $("[name='r1']"), and for some reason it returns null. Ok, fine, the title is misleading in that it is me that is doing something wrong; can you tell me what?
EDIT:
$('input[name="r1"]') doesn't work either. Also, sorry for the typo.
Html Code
<input type="text" name="r1" />
Jquery Code
$(document).ready(function() {
alert($('input[name="r1"]').length);
});
OLD Updates
you have typo error here you are trying to find r2 element which is not there just update code like $("[name='r1']")
or
to find it proper way you should do as below
$("input[name='r2']") instead of $("[name='r2']") only
EDIT
According to you edited question you should check example over here : Attribute Equals Selector [name="value"]
EDIT
for proper check you can do like this
$(document).ready(function() {
alert($('input[name="r1"]').length);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With