开发者

jQuery / javascript watch for new elements created in contenteditable space

开发者 https://www.devze.com 2023-04-05 14:45 出处:网络
This is an curiosity question.I can do without it, but was wondering if it\'s possi开发者_C百科ble to do.

This is an curiosity question. I can do without it, but was wondering if it's possi开发者_C百科ble to do.

I have a contentEditable div that a user can input text into. They can optionally edit the html and add divs with html. I'd like to look for a div with a specific class that they might create....such as <div class="random"></div> and do something with that element.

Is there a "created" event with javascript or jQuery that I can watch for?

jQuery(".random").live("created", function(){});

I realize I can watch the DOMSubtreeModified, but that adds a lot of overhead...especially since people will be typing on the page. It will push an event every time someone types a letter.

Anyways, if you can think of something, would be fun to know.


The only way i know is to use the livequery plugin, but it's very old (i think it has been discontinued since the live() function appeared in jquery)

0

精彩评论

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