Home > Web Front-end > JS Tutorial > body text

How to get the value of text box in jQuery?

藏色散人
Release: 2019-03-28 10:38:51
Original
4137 people have browsed it

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>
Copy after login

javascript code is as follows:

$( "input" )
  .keyup(function() {
    var tvalue = $( this ).val();
    console.log(tvalue);
  }).keyup();
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!