如何在运行时添加按钮以及如何对该按钮执行onclick事件 [英] how to add button at run time and also perform onclick event to that button

查看:48
本文介绍了如何在运行时添加按钮以及如何对该按钮执行onclick事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好....
我在运行时添加了一个按钮
但我无法执行onclick事件,因此无法执行该事件

hi to all....
i add a button at run time
but i cant perform onclick event, its not execute the event

var bt = document.createElement('input');
                bt.type='button';
                bt.id='btremoveval';
                bt.value='Remove';
                bt.onclick='move_back()';







function move_back(obj)
   {
    alert('hi');
   }


事件未执行..


event is not execute..

推荐答案



请查看此问题中的答案 [ ^ ]

希望您能从上面的链接中得到答案,如果您有任何疑问,请告诉我.

谢谢
-Amit Gajjar.
Hi,

Please have a look into answer in this question[^]

Hope you got answer from above link, Let me know if you have any query.

Thanks
-Amit Gajjar.


var bt = document.createElement('input');
                bt.type='button';
                bt.id='btremoveval';
                bt.value='Remove';
                //bt.onclick='move_back('+val+')';
                bt.onclick=function(){ move_back(val)};




它的工作感谢您的答复




it working thanks for ur reply


这篇关于如何在运行时添加按钮以及如何对该按钮执行onclick事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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