I’m trying to make a button visible only when quantity of items on cart changes (just like on ebay shopping cart). I did it but it doesn’t works as expected link, someone knows an easier or different way to do it??
I’m trying to make a button visible only when quantity of items on cart changes (just like on ebay shopping cart). I did it but it doesn’t works as expected link, someone knows an easier or different way to do it??
2
Answers
Try this (jquery):
Script is quite self-explanatory. If you need further explain, please comment.
fiddle: https://jsfiddle.net/qkLfftoo/7/
Note: This script is to provide better user experience and not meant for validation. Please use back-end validation to ensure entry is not negative integer.
For multiple buttons:
fiddle: https://jsfiddle.net/qkLfftoo/27/
As it is a front-end development part, you can use jQuery. Using jQuery to disable a button has many advantages as it will allow you to enable and disable the button based on user interaction. You will easily be able to use this code with other jQuery implementations.
You can check following tutorial for more reference.
https://blog.revillweb.com/jquery-disable-button-disabling-and-enabling-buttons-with-jquery-5e3ffe669ece
https://www.formget.com/enable-disable-button-jquery/