jQueryはtextareaテキストフィールド値を取得します
Jquery Get Textarea Text Field Value
.val jQuery()メソッドは、フォーム要素の値を取得するように設計されていますが、textareaフォーム要素を()メソッドにして直接.valを取得することもできます。ただし、textareaが二重にラベル付けされているため、.text()または.html()メソッドも情報を取得できますが、.val()は取得メソッドの値専用であるため、これは取得をお勧めしません。比。 text()または.html()の方が信頼性が高く、.text()および.html()は値を取得できない場合があります。
$(function(){
-
$ ( '# Demo') val (123). // modify the contents of the textarea to 123
-
$ ( '# Demo') text (456). // The content of the textarea revised to 456
-
// display on the last page is acquired and 123
-
// You can try to reverse the order of modification of the above process, the final result was 123
-
// pop textarea value alert ($ ( '# demo') val ().)
-
})
-
test
-
if($('#txt').val().trim().length == 0) {
return
}
trim () Clear a space character before and after the text