最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Span element change event - Stack Overflow

programmeradmin3浏览0评论

My question is:

Does have a span element the inner html change event? I think about I have a span and when the span inner html is changing it will throw an event that I can reach?

I would like to use Jquery to bind to this event of span.

l.

My question is:

Does have a span element the inner html change event? I think about I have a span and when the span inner html is changing it will throw an event that I can reach?

I would like to use Jquery to bind to this event of span.

l.

Share Improve this question asked Jun 1, 2010 at 13:01 user295541user295541 1,0154 gold badges16 silver badges26 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 6

From the jQuery documentation:

The change event is sent to an element when its value changes. This event is limited to <input> elements, <textarea> boxes and <select> elements.

At the moment, such events are not supported by browsers like IE, but what you are looking for is DOM events. See https://developer.mozilla/en/DOM_Events for more information.

No. As a rule of thumb, if something internal to a script changes something, it will not trigger an event.

Nothing external to a script can edit the innerHTML of a span (unless, perhaps, it is contentEditable) so there is no event.

Why not handle it when you make the change?

function updateHTML(el,newhtml,callback){
    el.innerHTML=newhtml;
    if(typeof callback=='function')callback(el);
}
发布评论

评论列表(0)

  1. 暂无评论