Manish Vadher Manish Vadher - 6 months ago 17
Javascript Question

http://bharatjethava.com stop LI onlick but want to call accept and reject button click

while click on li than want to call getchat funcation.but when click on accept and reject than also call LI click.want to stop this two times. http://bharatjethava.com

<li onclick="getchat(this,23,'ankit patel',32565,1119)" class="<divclass="status"></div>
<div class="user_image">
<img width="24" height="24" class="userimagechat" src="../Contentimage/32565/profile.jpg?e13a6f42?random=1462861613328?random=1462861614562?random=1462861615403?random=1462861616392" alt="">
</div>
<div class="user_info">

<span class="pull-right dt">22 minutes ago</span>
<span class="name">ankit patel<span>- ankit Diamond</span></span>
<div class="clearfix"></div>
</div>
<div class="user-chat-btn">
<ul>
<li class="accept-btn"><a class="clsaccept" onclick="acceptleadreq(this,23,32565)">Accept</a></li>
<li class="reject-btn"><a class="clsreject" onclick="rejectleadreq(this,23,32565)">Reject</a></li>
</ul>
</div>
</li>

Answer

Manage click in a single function by checking the class name. HTML :

                                         <span class="pull-right dt">22 minutes ago</span>
                                            <span class="name">ankit  patel<span>- ankit Diamond</span></span>
                                            <div class="clearfix"></div>
                                    </div>
                                    <div class="user-chat-btn">
                                        <ul>
                                            <li class="accept-btn"><a class="clsaccept" >Accept</a></li>
                                            <li class="reject-btn"><a class="clsreject" >Reject</a></li>
                                        </ul>
                                    </div>
                                </li>

Javascript:

function getchat(obj,a,b,c,d) {
    if($(obj).hasClass('clsaccept') || $(obj).hasClass('accept-btn')) {
        acceptleadreq(obj, a, c);
        return; 
    } else if($(obj).hasClass('clsreject') || $(obj).hasClass('reject-btn')) {
        rejectleadreq(obj, a, c);
        return; 
    } else 
// Do as required


}