$(".eventer button[name=myBtn]").click(function() {
console.log('clicked');
thisBtn = $(this);
parent = $(this).parent();
num = parent.data('num');
id = parent.data('id');
if(typeof num != 'number'){
num = 0;
}
$(this).attr('disabled', true);
$.post('javas.php', {num: (num-1), id: id}, function(data) { console.log('Ajax success');
parent.next('.status').html(data);
thisBtn.attr('disabled', false); // reset });
console.log('Ajax success');
parent.data('num', --num);
parent.next('.status').html(data);
thisBtn.attr('disabled', false); // reset
} );
} );
console.log('-- end');
});
How would i get the id of the class that has been clicked on, this is what i have so far, i want to send the id of the post along with the value of num (already being sent). How would i do this, thanks any help is appreciated!
To get the id, simply do
var id = this.id;EDIT:
$(this).attr('id')also works, but why do it the hard way?this.idis pure Javascript