Adding img to div on load
Is there a way to add a specific img to every element of class .myClass on its creation?
I tried this, and it doesn't work..
$('.myClass').live('load', functio开发者_StackOverflow社区n() {
$(this).prepend('<img src="..." />');
});
My final goal is, to be able to create a modal box (or a light box) by just creating a div of class myClass, so I don't have to add the closing image tag (for closing the modal box) for each modal box
There might be a better way than what i'm about to suggest, but i use livequery to get that working. Livequery listen's for the moment the element appears in the DOM.
$('.myClass').livequery(function() {
$(this).prepend('<img src="..." />');
});
If anyone knows of a better way, i'd love to see it too
加载中,请稍侯......
精彩评论