Home Web Front-end JS Tutorial Spin Button custom text box value increases or decreases based on jQuery_jquery

Spin Button custom text box value increases or decreases based on jQuery_jquery

May 16, 2016 pm 06:23 PM
button spin text box

Sometimes when designing a form, you need to implement a value auto-increment or auto-decrement function for the text box. For example, the default is 1. Click the up button to increase the specified step value, and click the down button to decrease the specified step value. Use the jQuery plug-in jQuery Spin Button only requires a few lines of code to implement this function. The effect is as shown below
Spin Button custom text box value increases or decreases based on jQuery_jquery
Instructions for use
1. You need to use the jQuery library file and jQuery Spin ButtonLibrary file (current version 1.1.1)

Material preparation
Up and down button pictures, the default path is:/img/spin/, the up and down button pictures are named: spin-button.png, Custom modifications can be made

Example code
1, including the file part

Copy code The code is as follows:




2. HTML part (custom text box)
Copy code The code is as follows:



Three , the javascript part (called by jQuery plug-in jQuery Spin Butt)
Copy code The code is as follows:

< ;script type="text/javascript">
$(document).ready(function(){
$('#number').spin();
});
< ;/script>

As you can see from the above, it is very simple to use the jQuery plug-in jQuery Spin Button to customize the text box value to increase or decrease. You only need to set the button image and the initial value of the value. Implement the function of self-increasing or decrementing the value of the custom text box.

Four, user-defined configuration
imageBasePath: '/img/spin/', button image path
spinBtnImage: 'spin-button.png', image button image name
spinUpImage: 'spin-up.png', the image name of the upward increment button
spinDownImage: 'spin-down.png', the image name of the downward decrement button
interval: 1, step value
max: null , maximum value
min: null, minimum value
timeInterval: 500, click time interval
timeBlink: 200 click blink time

1, custom step value is 10 (the code is the same as above javascript part)
$('#number').spin({interval:10});

2, customize the maximum and minimum values ​​
$('#number').spin( {max:100,min: -100});

3, Custom button image path
$('#number').spin({imageBasePath: '/images/'});

The jQuery plug-in jQuery Spin Button custom configuration is very convenient for customizing the personalized text box value auto-increment and decrement function, and it is also very simple to use. In general, the custom text box value auto-increment or decrement is used The jQuery plug-in jQuery Spin Button can be easily completed with one line of code.
View the demo: http://demo.jb51.net/js/jquery-spin/index.html
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to set a picture as the background in OneNote How to set a picture as the background in OneNote May 14, 2023 am 11:16 AM

Onenote is one of the best note-taking tools offered by Microsoft. Combined with Outlook and MSTeams, Onenote can be a powerful combination for increasing productivity at work and in personal creative productivity. We have to take notes in a different format, which may be more than just writing things down. Sometimes we need to copy images from different sources and do some editing in our daily work. Images pasted on Onenote can go a long way if you know how to apply the changes. Have you ever encountered a problem when using Onenote that images pasted on Onenote cannot allow you to work easily? This article will look at using images effectively on Onenote. we can

How to hide text until clicked in Powerpoint How to hide text until clicked in Powerpoint Apr 14, 2023 pm 04:40 PM

How to hide text before any click in PowerPoint If you want text to appear when you click anywhere on a PowerPoint slide, setting it up is quick and easy. To hide text before clicking any button in PowerPoint: Open your PowerPoint document and click the Insert menu. Click on New Slide. Choose Blank or one of the other presets. Still in the Insert menu, click Text Box. Drag a text box onto the slide. Click the text box and enter your

How to set button size and color in html How to set button size and color in html Mar 05, 2021 pm 05:16 PM

In HTML, you can use the width and height attributes to set the size of the button element, and use the background-color attribute to set the color of the button element. The specific syntax is "button{width: width value; height: height value; background-color: color value;}".

How to make a calendar in Word How to make a calendar in Word Apr 25, 2023 pm 02:34 PM

How to Make a Calendar in Word Using Tables If you want to create a calendar that fits your specifications exactly, you can do everything from scratch using tables in Word. This allows you to design the exact layout you want for your calendar. Create a calendar using tables in Word: Open a new Word document. Press Enter a few times to move the cursor down the page. Click the Insert menu. In the ribbon, click the table icon. Click and hold the upper left square and drag out a 7×6 table. Write the day of the week on the first line. Use another calendar as a reference to fill in the days of the month. Highlight any date outside the current month. In the main menu, click the text color icon and select Gray. For the current month, start with

What are the types of html text boxes? What are the types of html text boxes? Oct 12, 2023 pm 05:38 PM

HTML text box types include single line text box, password text box, number text box, date text box, time text box, file upload text box, multi-line text box, etc. Detailed introduction: 1. The single-line text box is the most common type of text box, used to accept single-line text input. The user can enter any text in the text box, such as user name, password, email address, etc.; 2. The password text box is used To accept password input, when the user enters the password, the content in the text box will be hidden to protect the user's privacy; 3. Numeric text box, etc.

How to add line breaks in HTML textbox? How to add line breaks in HTML textbox? Sep 04, 2023 am 11:05 AM

To add a newline character to an HTML text area, we can use the HTML newline tag to insert a newline character anywhere. Alternatively, we can also use the CSS property "white-space:pre-wrap" to automatically add line breaks to the text. This is particularly useful when displaying preformatted text in a text area. So let’s discuss ways to add line breaks. Method creates a text area in HTML and assigns it an id. Create a button that, when clicked, will split the text of the text area using line breaks. Now create a function that separates text into newlines. The code of this function is -functionreplacePeriodsWithLineBreaks()

How to write HTML scroll bar text box code How to write HTML scroll bar text box code Feb 19, 2024 pm 07:38 PM

Title: How to write HTML text box code with scroll bar The text box in HTML is one of the commonly used user input controls. In some cases, when the text content is too long, the text box will be displayed incompletely. At this time, we can add a scroll bar to the text box to support scrolling. This article will introduce in detail how to write HTML text box code with scroll bar effect, and give specific code examples. 1. Use the textarea element to create a text box. In HTML, we use the textarea element to create a text box.

How to set the text box border to be transparent How to set the text box border to be transparent Jul 28, 2023 am 10:05 AM

How to set the text box border to be transparent: 1. Open the document, select the inserted text box, right-click and select "Format Object"; 2. In the pop-up box on the right, select "Shape Options" - "Fill and Line" - "Transparency" ”; 3. Adjust the transparency as needed.

See all articles