I have the following:
$('#TopicRowKey')[0].value,
When I check using IE debugger and do a watch on the object I see it has a value. But when the script runs it comes up with a message saying: 0.value is null or not an object
Can someone explain if it’s related to the [0]. I don’t really understand with jQuery what the [0] is for.
<select id="Topic" name="TopicRowKey">
<option value="01">aa</option>
<option value="02">bb</option>
</select>
- Note that I realized one thing that’s wrong. My id name is not correct 🙁 I looked at this for so long and didn’t see it in the code.
jQuery returns an array-like object.
This means it is an object that can be traversed as if it was an array.
When you do $(“#myId”)[0], it returns the actual element of the page.
That is, your jQuery sintax is correct. Perhaps this element does not support a value (like a div, for example), or you’re making a mistake somewhere else. You’ll have to provide full code for us to see what is actually wrong.
Here is a fiddle with a working example:
http://jsfiddle.net/SW5Hz/
Edit:
You’re searching for the wrong id. It should be
or
The # are meant for id only. If you want to search for name, do:
or