I have an input –
<input id="post_name" type="text" value="123" name="post_name">
This input is contained within a <div> that is hidden when the page loads, and jQuery will not retrieve the value of the input –
var current_name = $('input[name="post_name"]').val();
I can read the rest of the object, and get attirbutes such as name and id, but the value is eluding me. Is this a jQuery bug, or am I missing something?
The answer here is depressingly simple – I accidently duplicated to ID and name that I was using for the input earlier in my code, so it was that which was being picked up by the jQuery.
The lesson I’ve learned – don’t be a donut! And check your code to ensure that selector IDs and input names are not duplicated.