I'm using jQuery with the power of localStorage.
Here is what I have:
<textarea name="localStorageString" id="localStorageString"></textarea>
<script>
var userJson = localStorage.getItem('userJson');
$('#localStorageString').html(userJson);
$('#localStorageString').keyup(function(){
alert($(this).html());
});
The textarea is correctly filled, the problem is when I modify it, it always alerts the same value (set by html(userJson)).
Any idea ?
You need $(this).val() to get the value of a form element.
I forgot this one. Why
.html()doesn't work ?
html() - it's the native JavaScript .innerHTML function. It takes everything (all the nodes) inside the tag as a string.
<div id="Node">
<a href="#">Hello</a>
</div>
console.info($('#Node').html()); // <a href="#">Hello</a>
val() - that's form.element.value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With