I'm trying to write different PHP code for different HTML <button> elements, but apparently it applies to all the buttons on the page. Here's one of my buttons:
<button name="plus" id="plus" type="button" onclick="plus()">+</button>
Here's the function I tried to make, it applies to all the buttons on the page:
$(document).ready(function() {
$("button").click(function() {
$.ajax({
type: 'POST',
url: 'plus.php',
success: function(data) {
//
}
});
});
});
The questions:
How do I write functions for specific buttons?
Why do I have to write type="button" for them to work?
Where do I write AJAX functions? In
<head></head>or anywhere in the body?