可能性の重複:
Finding class where button is clickedポストではない、すべてのクラス
<script>
var num = 1;
function ajax_post(){
$.ajax('javas.php', {
success: function(response) {
$(".status").html(response);
},
data: "num=" + (++num)
});
}
function ajax_posta(){
$.ajax('javas.php', {
success: function(response) {
$(".status").html(response);
},
data: "num=" + (--num)
});
}
$(document).ready(function() {
$('.eventer > .button').click(function() {
ajax_post();
});
alert("lol");
});
</script>
は、しかし、これは私が欲しい、名前のステータスを持つすべてのクラスに掲示されますそれは、送信ボタンがクリックされたクラスにのみポストするため、クラスがwhileループで生成されるので、多くの重複クラスが存在します。 これはPHPで生成されたHTMLですwhileループ:
echo " <div class = 'eventer'> $timeposted <br>$eventlist <button name='myBtn' type='button' onClick='javascript:ajax_post();'>Inc</button>
<button name='lol' type='button' value='dec' onClick='javascript:ajax_posta();'></button></div>
<div class = 'status'>sigh</div>";
エコー "
"。
あなたはHTML部分を見せていただけますか? – Quasdunk
私たちはあなたのhtmlを参照する必要があります – aWebDeveloper
ちょうど私の質問 – foshoeiyyy