在div中使用onchange [英] Use onchange in a div

查看:429
本文介绍了在div中使用onchange的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以在< div>

$ b $中使用 onchange 事件吗? b

因为我的< div> 在里面改变它的文字。

我可以这样做吗?

 < div id =nameonchange =calculateTotal();>< / div> 


解决方案

既然你说你在使用AJAX,在更新文本时执行该功能。我不确定你是否使用任何库,但如果它是jQuery的话:

  $ .ajax({.. 。,
成功:function(){
...其他东西...
...设置div文本...
calculateTotal();
}
});


Is it possible to use onchange event in a <div>?

Because my <div> changes its text inside.

Can I do something like this?

<div id="name" onchange="calculateTotal();"></div> 

解决方案

Since you say you're using AJAX, why not execute the function when you update the text. I'm not sure if you use any library, but in case it's jQuery just do:

 $.ajax({ ...,
          success: function() {
               ... other things ...
               ... setting div text ...
               calculateTotal();
          }
       });

这篇关于在div中使用onchange的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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