Reputation: 850
I'm new to javascript & jquery. i have a textarea with a preset content. If i change the value on the site by entering "new" and press the "showme" button the alert box does show me the preset value, not the new contend of the textarea.
Why is this? What i have to change to get the new content from my chrome browser?
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<form action="javascript:Output()">
<textarea id='area1'>preset</textarea>
<input type="submit" value="showme">
</form>
<script>
function Output() {
var s = $('#area1').html();
alert(s);
}
</script>
Upvotes: 1
Views: 70
Reputation: 27765
You need to use val
method
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<form onsubmit="Output()">
<textarea id='area1'>preset</textarea>
<input type="submit" value="showme">
</form>
<script>
function Output() {
var s = $('#area1').val();
alert(s);
}
</script>
Upvotes: 5