


Function code for adding and subtracting the number of shopping cart items implemented by jQuery
The example in this article describes the function of adding and subtracting the number of shopping cart items implemented by jQuery. Share it with everyone for your reference, the details are as follows:
Today, netizen Cui Er encountered a problem when using Jquery to implement the special effect of adding and subtracting the number of items in the shopping cart and asked me. I later helped her solve this Jquery special effect, and now it I compiled it and shared it for everyone to use. Although the function is relatively simple, it is very practical.
Mainly includes the following functions:
1. Quantity increase operation function
2. Quantity reduction operation function
3. Total price calculation function
4. When the quantity is automatically judged to 1, the decrease operation button is prohibited from clicking. Automatically restore when the quantity increases
5. The toFixed() function to retain the number of decimal points is very practical
The function code is as follows:
$(function(){ //获得文本框对象 var t = $("#text_box"); //数量增加操作 $("#add").click(function(){ t.val(parseInt(t.val())+1) if (parseInt(t.val())!=1){ $('#min').attr('disabled',false); } setTotal(); }) //数量减少操作 $("#min").click(function(){ t.val(parseInt(t.val())-1); if (parseInt(t.val())==1){ $('#min').attr('disabled',true); } setTotal(); }) //计算操作 function setTotal(){ $("#total").html((parseInt(t.val())*3.95).toFixed(2));//toFixed()是保留小数点的函数很实用哦 } //初始化 setTotal(); })

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Atom editor mac version download
The most popular open source editor

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Chinese version
Chinese version, very easy to use
