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 to realize the function of Digital input Box with jquery

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article introduces the relevant knowledge of "how to achieve the function of digital input box in jquery". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

The effect is as follows:

The code is as follows:

# reduce,#add {width: 50px; height: 50px; text-align: center; line-height: 50px; border: 1px solid # 000000; font-size: 28px; font-weight: bold; float: left; cursor: pointer;} # numVal {width: 100px; height: 46px; text-align: center; line-height: 46px; float: left;}-+ $(function () {var setInitVal=20;// initialization var setMax=30;// setting maximum var setInterval=2 / / set the interval $("# numVal") [0] .value = setInitVal; $("# reduce") .click (function () {$("# numVal") [0] .value = Number ($("# numVal") [0] .value)-setInterval; if ($("# numVal") [0] .value)

< 0) { $("#numVal")[0].value = 0; } if($("#numVal")[0].value >

< 0) { $("#numVal")[0].value = 0; } }) $("#numVal").on("blur", function() { if($("#numVal")[0].value >

SetMax) {$("# numVal") [0] .value = setMax } if ($("# numVal") [0] .value < 0) {$("# numVal") [0] .value = Math.abs ($("# numVal") [0] .value)} $("# numVal") [0] .value = Number ($("# numVal") [0] .value) if (($("# numVal") [0] .value) = "NaN") {$("# numVal") [0] .value = 1 })}) this is the end of the introduction of "how to realize the function of digital input box in jquery". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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