Reputation: 91
I have 2 buttons, one to reduce quantity and one to add quantity. The html codes for the button are like this.
<button id='plusqty' type='button' value='".$row['idshoppingcart']."' class='btn btn-default btn-number' >+</button>
<button id='minusqty' type='button' value='".$row['idshoppingcart']."' class='btn btn-default btn-number' >-</button>
and the ajax code for the minus button
$("#minusqty").click(function(){
var action = 'data';
var type = '-';
$.ajax({
url:'changeqty.php',
method: 'POST',
data:{action:action,type:type,id:$(this).val()},
success:function(response){
$("#result").html(response);
}
});
});
I use the same ajax method with other buttons in my website, such as the add to cart function, and it works fine. But this one in particular doesn't work. I click the "+" button and nothing even happens at all which leads me to believe the jquery listener is not firing. Any advice? Thanks a lot!
EDIT: i changed to a the ajax listener to a class selector as someone has mentioned, still doesn't work though.
Upvotes: 1
Views: 5457
Reputation: 176
You are using a class selector:
$(".minusqty").click(function(){
Use an id selector instead:
$("#minusqty").click(function(){
Upvotes: 3