how default value of textarea using jquery. referred following question default text on textarea jquery? getting undefined answer
html:
<textarea id="comments">dsfdtert</textarea>
jquery:
$(document).ready(function(){ alert($('#comments').data('defaultval')); });
see fiddle : http://jsfiddle.net/kritika/7cmec/
on pageload, you'd use text()
or val()
methods default text in textarea:
$(document).ready(function(){ alert($('#comments').text()); });
to set default text data variable later use, you'd do:
$(document).ready(function(){ $('#comments').data('default', $('#comments').text()); });
and later can call
var default = $('#comments').data('default');
to retrieve it
Comments
Post a Comment