Jquery只在dymanic按钮点击中点击一次 [英] Jquery hits only once in dymanic button clicks

查看:87
本文介绍了Jquery只在dymanic按钮点击中点击一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好专家,



我有一个网络应用程序,有一个更新面板。

在更新面板中,有一个div。

从后面的代码中,我创建了一个像布局一样的表格,比如100个单元格。像每10行10个细胞。

每个单元格都有一个分配了文本的按钮。

到目前为止,一切都很完美。以下是从浏览器中的调试器资源工具中挑选的html

Hello experts,

I have a web application,in there is a Update panel.
In the Update panel, there is a div.
From code behind, I am creating a table like layout with say 100 cells over all. like 10 cells in each 10 rows.
Every cell has a button with text assigned.
To this point everything is perfect. Here is the html picked from debugger resource tools in browsers

<th class="thbut">
<input class="thbut" type="submit" style="background-color:#CCEEDD;height:30px;width:60px;" value="AA096" name="ctl03">
</th>
<th class="thbut"> <pre><input class="thbut" type="submit" style="background-color:#CCEEDD;height:30px;width:60px;" value="AA094" name="ctl04">
</th>





我有一个Jquery功能。每次单击一个按钮时,它都必须提醒按钮的名称/文本,这就是问题所在。它只工作一次。这意味着当我第一次点击按钮时,它会弹出警告,并显示按钮的名称。单击下一步按钮将不执行任何操它没有击中Jquery事件。两者都没有显示任何错误。



And I have a Jquery function. Every time a button is clicked it has to alert the name/text of the button and here comes the problem. It works only once. Meaning first time when I click on the button, it pops up alert with the name of the button. Next button click will do nothing. It doesn't hit the Jquery event. Neither shows any errors.

function ClickManager(element) {
            debugger;
            this.el = $(element);
            this.check = function () {
                if (this.el.hasClass('thbut')) {
                    alert(this.el.val());
                }
            };
        }


        $(document).ready(function () {
            debugger;
            //on and live are same 
        $('.thbut').on('click', function () {
                manager = new ClickManager(this);
                manager.check();
            });
        });







有人可以帮我吗?



我尝试过的事情:



我试过做$(文件).ready(function(){

调试器;

// on a nd live是一样的

$('。thbut')。on('click',function(){

manager = new ClickManager(this);

manager.check();

});

});

函数内部并在代码隐藏的属性中添加。就像evey按钮有onclick = Hit();功能。似乎没有什么工作




Could someone please help me in this?

What I have tried:

I have tried doing the $(document).ready(function () {
debugger;
//on and live are same
$('.thbut').on('click', function () {
manager = new ClickManager(this);
manager.check();
});
});
inside a function and add that in attributes from codebehind. Like evey button has onclick = Hit(); function. Nothing seems to work

function ClickManager(element) {
           debugger;
           this.el = $(element);
           this.check = function () {
               if (this.el.hasClass('thbut')) {
                   alert(this.el.val());

               }
           };
           return false;
       }
       $(document).ready(function () {
           $(document).on('click', '.thbut', function () {
               manager = new ClickManager(this);
               manager.check();
           });
       });

推荐答案

(元素);
.check = function (){
if this .el.hasClass(' thbut')){
alert( this .el.val());
}
};
}
(element); this.check = function () { if (this.el.hasClass('thbut')) { alert(this.el.val()); } }; }


document )。ready( function (){
调试器;
// on and live相同
(document).ready(function () { debugger; //on and live are same


' .thbut')。on(' click'功能(){
manager = new ClickManager( this ) ;
manager.check();
});
});
('.thbut').on('click', function () { manager = new ClickManager(this); manager.check(); }); });







有人可以帮我吗?



我尝试过的事情:



我尝试过




Could someone please help me in this?

What I have tried:

I have tried doing the


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

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