2

Possible Duplicate:
Is there a jQuery DOM change listener?

there is a way to have a js function loaded or to call that function every time when dom is modified? I have a html page on which I expand another panel in the same page from an action button in this way the dom is modified and my js function is not called any more :|

7
  • stackoverflow.com/questions/1091661/… stackoverflow.com/questions/2844565/… Commented Oct 17, 2012 at 8:21
  • No, but you could create a custom event and fire it every time you are done modifying the DOM. Commented Oct 17, 2012 at 8:21
  • Working example to detect dom change - jsfiddle.net/eQErD/1 Commented Oct 17, 2012 at 8:25
  • Please look ---------------> there are several Commented Oct 17, 2012 at 8:26
  • @bhb I use it in this way but not really working :( <script type="text/javascript"> $(".primary").bind("DOMSubtreeModified", function() { if (window.PIE) { $('.primary,.secondary,input[type = "text"],.nopadd').each(function(){ PIE.attach(this); }); } alert("tree changed"); }); </script> Commented Oct 17, 2012 at 8:56

1 Answer 1

3

Code

$("#a").bind("DOMSubtreeModified", function() { if (window.PIE) { $(this).each(function() { PIE.attach(this); }); } alert("tree changed"); }); $("#add").click(function() { $("#a").append("<span>hey there</span>"); }); ​ 

HTML:

<div id="a"></div> <button id="add">Add to Div</button>​ 

Working fiddle

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.