bwoogie
bwoogie

Reputation: 4427

jQuery getting item values

I'm making a form on a wordpress blog that uses ajax. I'm trying to grab some values from a form and when I call:

var name = jQuery("#name").val();

it's empty. That is unless i hardcode the value like:

<input type="text" name="name" id="name" value="myname"/> why is that?

Upvotes: 1

Views: 61

Answers (1)

j08691
j08691

Reputation: 207901

When are you running your var name = jQuery("#name").val();? On a click? On DOM ready? Make sure the data is there before you try to get it ;)

Upvotes: 1

Related Questions