Use .val()
to get value of textarea and use $.trim()
to empty spaces.
$(document).ready(function () {
if ($.trim($("textarea").val()) != "") {
alert($("textarea").val());
}
});
Or, Here's what I would do for clean code,
$(document).ready(function () {
var val = $.trim($("textarea").val());
if (val != "") {
alert(val);
}
});
Demo: http://jsfiddle.net/jVUsZ/