There is a list of products, it can consist of 4 items, maybe 99, etc. Each element is assigned its id:
<div class="item" id="item-20">Товар 20</div> <div class="item" id="item-56">Товар 56</div> <div class="item" id="item-31">Товар 31</div> ... <div class="item" id="item-47">Товар 47</div> The task is as follows: Using jQuery, organize sending the button with the id specified in it to the PHP script and replace this button with the response from the PHP script
<div class="item" id="item-20">Товар 20 | <button id="off-item-20">Отключить</button></div> <div class="item" id="item-56">Товар 56 | <button id="off-item-56">Отключить</button></div> <div class="item" id="item-31">Товар 31 | <button id="off-item-31">Отключить</button></div> ... <div class="item" id="item-47">Товар 47 | <button id="off-item-47">Отключить</button></div> In the case of a single element I use
$(document).on('click','.class',function(e){ e.preventDefault(); var id = jQuery(this).data('id') || 0; $("#content").load("/ajax.php",{action:"getResult", id:id}); }); But here you need something else.
I would be grateful for any help!