找到所在的班级被点击按钮 [英] Finding class where button is clicked

查看:103
本文介绍了找到所在的班级被点击按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我有问过这个问题很多次,但我仍然havnt发现分辩答案。

I know i have asked this question many times but i still havnt found the rigth answer.

NUM需要显示在仅在类的按钮被点击在

num needs to be displayed in ONLY the class that the button was clicked in.

<script>
var num = 1;
function ajax_post(obj){
$.ajax('javas.php', {   success: function(response) {     $(obj).parent().next('.status').html(response);   },    
data: "num=" + (++num)   });   } 

function ajax_posta(obj){
 $.ajax('javas.php', {   success: function(response) {        
 $(obj).parent().next('.status').html(response);
   },    
    data: "num=" + (--num)   });   } 

    $(document).ready(function() {
    $('.eventer > .submit').click(function () {
        ajax_post(this);
    });
    alert("lol");
    });


</script>

<br>
<div id = 'eventcontainer' >

创建Eventer类和状态类(多次,因为它是在一个while循环(在code没有指定)

Eventer Class is created as well as status class (multiple times as it is in a while loop (not specified in the code)

    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();'>dec</button></div>
    <div class = 'status'>sigh</div>";
    echo "<br>";


    }



    </div>

当我点击任何一类的按钮,而NUM应该只显示在eventer类的按钮被点击其中类

什么也没有发生。

Nothing happens when i click the buttons in any class, whereas num should display in only the class where the button in the eventer class was clicked.

请帮助谢谢

推荐答案

的onClick =JavaScript的:ajax_posta();

的onClick ='ajax_posta()

您确认结果为阳性?你问的问题的质量非常差,我真的不能明白你问。

Are you sure the result is positive? The quality of your asked question is very poor and I can't really understand what you are asking..

你是什么意思NUM需要显示的只有被点击的按钮中的类。

What do you mean by "num needs to be displayed in ONLY the class that the button was clicked in."

这篇关于找到所在的班级被点击按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆