如何在点击其他点击事件时触发点击事件? [英] How to trigger an click event on click of another click event?

查看:117
本文介绍了如何在点击其他点击事件时触发点击事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$(document).ready(function(){
$('#datatable tbody').on('click', 'td:nth-child(1), td:nth-child(5), td:nth-child(8), td:nth-child(11)', function (event) {
                if ($("#ValBool").val() == "false") {
                    Editable();
                }
                else {
                    event.stopImmediatePropagation();
                    alert("Not allowed");
                }
            });

function Editable(){

$('#datatable tbody').on('click', 'td:nth-child(1), td:nth-child(5), td:nth-child(8), td:nth-child(11)', function () {
                        
                        var x = $(".itemEdit").length;
                        var getData = $(this).html();
                        
                        //placing the data in the textbox again
                        if (x == 0) {
                            $(this).empty().html('<input type="text" value="' + getData + '" class="itemEdit" id="dataField"/>');
                            $('.itemEdit').focus();
                        }
});
}
</pre>









我想触发点击第一个事件的第二个事件。





问题是它只是在第一次加载页面时才被触发但是它工作正常







I want to trigger the second event on click on first event.


The problem is it is not getting triggered only the first time the page is loading but then it is working fine

The

$("#ValBool").val() == "false"

是我想要触发第二个事件的条件。

Is my condition for which i want to trigger the second event or not.

推荐答案

(文件).ready(function(){
(document).ready(function(){


' #datatable tbody')。on(' 点击'' td: nth-child(1),td:nth-​​child(5),td:nth-​​child(8),td:nth-​​child(11)',function(事件){
if
('#datatable tbody').on('click', 'td:nth-child(1), td:nth-child(5), td:nth-child(8), td:nth-child(11)', function (event) { if (


#ValBool)。val()== false){
Editable();
}
else {
event .stopImmediatePropagation();
alert( 不允许);
}
});

函数Editable(){
("#ValBool").val() == "false") { Editable(); } else { event.stopImmediatePropagation(); alert("Not allowed"); } }); function Editable(){


这篇关于如何在点击其他点击事件时触发点击事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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