开发者

Is there a event which is raised when something is added to a UL?

开发者 https://www.devze.com 2023-04-05 20:49 出处:网络
I am searching for an event which is raised when I add a new item to an UL-List. Is 开发者_JAVA技巧there something like that?

I am searching for an event which is raised when I add a new item to an UL-List. Is 开发者_JAVA技巧there something like that?

Thanks.


In short: no.

But you can trigger your own events in jQuery when you add those lis:

$('ul').bind('liAdded', function(){
    alert('An "li" was added!');
});

$('ul').append('<li>').trigger('liAdded');


You can try the following (haven't tested but seems promising): http://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMAttrModified

I'm not completely sure if its just a W3 standard thing or its actually put in use in modern browsers.

DOMAttrModified A user agent must dispatch this event after an Attr.value has been modified and after an Attr node has been added to or removed from an Element.


ie678 (CSS):

ul * {behavior: url(x.htc)}

and callback in x.htc:

<script type="text/javascript">
notify(this.element);
</script>

w3c standard:

document.addEventListener("DOMNodeInserted", function(e){...})
0

精彩评论

暂无评论...
验证码 换一张
取 消