How to add or subtract the quantity of goods in jQuery
This article mainly introduces jQuery how to achieve the number of goods plus or minus related knowledge, detailed and easy to understand, simple and fast operation, with a certain reference value, I believe that everyone will read this jQuery how to achieve the number of goods plus or minus articles will have some gains, let's take a look at it.
The specific codes are as follows:
$(document).ready(function(){//Get text box object var t = $("#text_box");//Initialize quantity to 1, and invalidate minus $('#min').attr ('disabled ',true); //Quantity increment operation $("#add").click(function(){ //Add the absolute value to val obtained, avoiding negative t.val(Math.abs(parseInt(t.val()))+1); if (parseInt(t.val())!= 1){ $('#min').attr ('disabled ',false); }; }) //Quantity reduction operation $('#min').click(function(){ t.val(Math.abs(parseInt(t.val())-1); if (parseInt (t.val())==1){ $('#min').attr ('disabled',true); }; })}); About "jQuery how to achieve the number of goods plus or minus" The content of this article is introduced here, thank you for reading! I believe everyone has a certain understanding of the knowledge of "jQuery how to realize the addition and subtraction of commodity quantity." If you still want to learn more knowledge, please pay attention to the industry information channel.