This article will introduce how to use jQuery to get the value of the text box. I hope it will be helpful to friends in need!
The following is a simple code example to introduce to you the jQuery method of obtaining the text box value.
HTML code example is as follows:
<!DOCTYPE html> <html> <head> <script src="https://code.jquery.com/jquery-git.js"></script> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <title>如何使用jQuery获取文本框的值</title> </head> <body> <input type="text" value="输入内容"> </body> </html>
javascript code is as follows:
$( "input" ) .keyup(function() { var tvalue = $( this ).val(); console.log(tvalue); }).keyup();
Output:
Note: The jQuery keyup() method indicates that the keyup event occurs when the keyboard key is released. The keyup() method triggers the keyup event, or specifies a function to run when the keyup event occurs.
Related recommendations: "jQuery Tutorial" "javascript Tutorial"
This article is about the method of getting the value of the text box with jQuery. Hope it helps those in need!
The above is the detailed content of How to get the value of text box in jQuery?. For more information, please follow other related articles on the PHP Chinese website!