Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Jquery Disabling individual buttons within search results that all have the same classes applied
- $("button.addtocart").click(function(e) {
- // fetch <input name='stock_amount'> within the clicked buttons form element
- var stock_amount_input = $("input[name='stock_amount']", $(this).parent());
- // fetch <input name='_qty'> within the clicked buttons form element
- var qty_input = $("input[name='_qty']", $(this).parent());
- // maybe you want to do some check here
- var new_amount = stock_amount_input.val() - qty_input.val();
- // set the new calculated value in the stock_amount input
- stock_amount_input.val(new_amount);
- // if the new_amount is less than 1 we dissable the clicked button
- if(new_amount < 1) {
- $(this).attr("disabled", "disabled");
- }
- });
- var nodes = $("form");
- for(var i=0; i<nodes.length; i++) {
- var node = nodes[i];
- // do something
- }
Add Comment
Please, Sign In to add comment