Reputation: 39148
I've got the following markup:
<textarea id="hazaa"></textarea>
When I execute the following JavaScript in the console:
$("#hazaa").value
I get the print-out of what's in the box. However, when I try to execute this:
$("#hazaa").value = "shazoo"
the console notifies me back with shazoo but the text in the box doesn't change. Also, subsequent check of what's in the box returns the old, unaltered value.
It's been a while since I've done any jQuery-ing so it's probably something fairly obvious but I can't think of any resolution. I've googled for suggestions but the best one I've found actually discusses properties that aren't there! What am I missing?!
Executing the following two lines:
$("#hazaa").val
$("#hazaa").val()
produces:
undefined
TypeError: Object # has no method 'val'
I trust fully that I'm to blame for it but I don't how how to proceed. :)
Upvotes: 3
Views: 8233
Reputation: 44740
You need to do this -
setter
$("#hazaa").val("shazoo");
getter
var val = $("#hazaa").val();
Demo -->
http://jsfiddle.net/E3kZy/1/
Upvotes: 3