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. :)
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. :)
Share Improve this question edited May 23, 2017 at 12:22 CommunityBot 11 silver badge asked Jun 7, 2013 at 9:33 Konrad VilterstenKonrad Viltersten 39.5k88 gold badges290 silver badges511 bronze badges 1-
$("#hazaa").val
is wrong. – Adil Shaikh Commented Jun 7, 2013 at 9:39
2 Answers
Reset to default 3You need to do this -
setter
$("#hazaa").val("shazoo");
getter
var val = $("#hazaa").val();
- http://api.jquery./val/
Demo -->
http://jsfiddle/E3kZy/1/
You can set value by using .val()
Set the value of each element in the set of matched elements.
$("#hazaa").val('Your text here');
.val()
You can get the value using $("#hazaa").val();
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744964266a4603577.html
评论列表(0条)