跨文本/ html触发器已更改 [英] Trigger for span text/html on changed

查看:94
本文介绍了跨文本/ html触发器已更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

span 标记文本/ html已被更改时触发的jQuery或JavaScript中是否有任何事件?

代码:

 < span class =user-location> < /跨度> 
$ b $('。user-location')。change(function(){
//不工作
});

提前致谢!

解决您可以使用 DOMSubtreeModified 来追踪span元素的变化,即(如果span元素的文本动态变化)。

$ b $('。user-location')。on('DOMSubtreeModified',function(){
alert('changed')

  

检查以下链接 https://jsbin.com/volilewiwi/edit?html,js,output


Is there any event in jQuery or JavaScript that triggered when span tag text/html has been changed ?

Code:

<span class="user-location"> </span>

$('.user-location').change(function () {
    //Not working
});

Thanks in advance!

解决方案

you can use DOMSubtreeModified to track changes on your span element i.e(if text of your span element changes dynamically ).

$('.user-location').on('DOMSubtreeModified',function(){
  alert('changed')
})

check out the followinf link https://jsbin.com/volilewiwi/edit?html,js,output

这篇关于跨文本/ html触发器已更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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