我想在 <span> </span>
时调用我的大型商业项目中的一个函数文本已更改,我想调用该特定函数。例如,如果标签包含 <span>Hi</span>
, 当文本 Hi
更改为 <span>Hello</span>
意味着我想调用函数 test()
.
function test(){
alert("Hi you are authorised for this page")
}
最佳答案
你可以这样尝试:
HTML:
<span id="mytext">Hi</span>
JQuery:
$('#mytext').on('DOMSubtreeModified',function(e){
if($(this).text() == 'Hello')
alert("Hi you are authorised for this page");
});
关于javascript - 在 span 中对 textchange 调用函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26055797/