Is there a event which is raised when something is added to a UL?
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 li
s:
$('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){...})
精彩评论