I’m working on a shopping cart for a client. We have up and down arrows next to product images to select the amount of an item you want to purchase. I’m trying to get this to automatically update the shopping cart also. So any item that has a value of more than one will automatically appear in the cart.
I have the up and down buttons working for each product but when I add in the code for the If statement it breaks everything. I’m also not sure I’m doing this properly because I would need an If statement for each product and there could be 70 products in the store.
Is there a way to use a variable in the If statement to get the matching cart div and make it show?
Here is a jsfiddle http://jsfiddle.net/richcoy/7XnXF/
I think this is what you’re looking for. You can use eq() to get a certain index and index to get the current index. Since you structured your
.cart_productdiv according to your otherdivyou can just get the current index of the clickeddivand use that to show/hide the correspondingdivhttp://jsfiddle.net/7XnXF/12/