| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 591 人关注过本帖
标题:js 修改 button 的事件值后 为什么新事件不能用
只看楼主 加入收藏
gesongs
Rank: 3Rank: 3
等 级:论坛游侠
威 望:3
帖 子:129
专家分:100
注 册:2011-7-7
结帖率:52.78%
收藏
已结贴  问题点数:10 回复次数:2 
js 修改 button 的事件值后 为什么新事件不能用
代码如下
 <input id="buttono" name="buttono" type="button" id="button" value="添 加" onclick="Add()"/>
<script>
function Add()
{
        document.getElementById("buttono").value="修 改";
        document.getElementById("buttono").onclick="Modi()";
}
function Modi()
{
 alert("modi")
}
</script>
上述代码  更改后的 事件 Modi() 不能启用  部能 弹出 modi 对话框
搜索更多相关主题的帖子: function button 对话框 
2012-05-31 11:22
hibill
Rank: 2
等 级:论坛游民
帖 子:3
专家分:20
注 册:2012-6-4
收藏
得分:10 
<script>
function Add()
{
        document.getElementById("buttono").value="修 改";
        document.getElementById("buttono").onclick=Modi;
}
function Modi()
{
alert("modi")
}
</script>
2012-06-04 08:07
wang582
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2012-6-4
收藏
得分:0 
回复 2楼 hibill
<script>
function Add()
{
        document.getElementById("buttono").value="修 改";
        document.getElementById("buttono").onclick = function(){Modi();}
}
function Modi()
{
alert("modi")
}
</script>
2012-06-13 13:26
快速回复:js 修改 button 的事件值后 为什么新事件不能用
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014277 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved