Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize the function of Digital input Box with jquery

Shulou Source: shulou.com Published: 2022-06-01 02:20:18 09月14日 Update

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!

Tags: Function number input content more knowledge practical maximum learned next code dilemma reality situation effect article maximum case tape website Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Xiaomi Shulou Tech Info OPPO Reno Redmi