Home >Web Front-end >JS Tutorial >How to get the value of text box in jQuery?

How to get the value of text box in jQuery?

藏色散人
藏色散人Original
2019-03-28 10:38:514225browse

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!

How to get the value of text box in jQuery?

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:

How to get the value of text box in jQuery?

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn