How to determine the press and run the function but at the same time use the same function for many repetitive forms. Now you understand what I mean.
There is such a form. On the page there may be several such depending on the number of rows in the database (not the essence).
<div> <textarea id="comment_menu"></textarea> <p id="submit-kom" iid="x">Отправить</p> </div> But the script defines the click and runs the function
$('#submit-kom').click(function(){ var comment = $("#comment_menu").val(); var iid = $("#submit_kom").attr("iid"); if (comment != ""){ comment_menu = '1'; $("#comment_menu").css("borderColor","#DBDBDB"); }else{ comment_menu = '0'; $("#comment_menu").css("borderColor","#FDB6B6"); } if ( comment == '1'){ $("#submit-kom").hide(); $.ajax({ type: "POST", url: "../xxx/xxx.php", data: "id="+iid+"&comment="+comments, dataType: "html", cache: false, success: function(data) { if (data == 'yes'){ $("#submit-kom").show(); } } }); } }); The problem is that there is more than one button on the page to оправить with id="submit-kom" and therefore the function does not work by clicking on one of the buttons. How to make everything work? maybe via onclick or something similar, it is necessary that js determines that the отправить button is pressed but with a specific индексом or id