Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How jquery removes spaces from input values

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article is about how jquery removes spaces from input values. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Jquery remove input value spaces: 1, use the val () method to get the input value, syntax "$(" input "). Val ()"; 2, use the trim () method to remove spaces, syntax "$.trim (input value)".

The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.

Implementation implementation:

First you need to get the input value, which requires the use of the val () method: $("input") .val ()

After you get the value, you can use the trim () method to remove the spaces of the value.

Implementation code:

$(document) .ready (function () {$("button") .click (function () {var value=$ ("input"). Val (); $("input") .val ($.trim (value));}) }); .intro {font-size: 120%; color: red;}

Remove the space from the input value

Thank you for reading! This is the end of the article on "how jquery removes the spaces of input values". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report