There is a chrome extension page popup.html:

<script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/popup.js"></script> <div id="wrapper"></div> <script type="text/javascript" src="js/store.js"></script> 

The text in the div is generated in popup.js

In store.js, I execute:

  var theValue = $('#wrapper').text(); console.log(theValue); 

and get an empty string (on the page it is not empty). What is the problem?

  • If you fill in a div through ajax , then you need to wait in store.js and catch when the div full. - user207618
  • how to implement it? - Bond
  • I would use either events or MutationObserver . - user207618
  • if I add elements to the div gradually, how to catch exactly the end of the popup.js operation via the MutationObserver function is called with each addition - Bond
  • Constantly pulling the DOM is bad, it is better to add everything at once. If there is no such possibility, put the done type flag and check it when checking mutations. - user207618

0