简体   繁体   中英

How to manipulate DOM that was created via JavaScript

The problem I currently run into is that I load a third party plugin via <script data-cfasync="false"> so the generated DOM from that is not directly accessible.

If it was directly accessible, then I could successfully change the DOM via

document.getElementsByClassName('conversations-header-name')[0].innerHTML = 'chatting with Chris';

Now, my question is: how can I modify the text that is created after the page was loaded and then displayed in the container of the class conversations-header-name without modifying the source code as it is a 3rd party plugin we use?

*edit The generated DOM through the plugin is displayed inside of a iframe.

This is something close to help..

 document.onreadystatechange = function () { var state = document.readyState; if (state == 'complete') { var e1 = document.getElementById('e1'); var e2 = document.createElement('div'); e2.setAttribute("id","e2"); e2.innerHTML = "Div 2"; e2.style.color ="red"; e1.append(e2); } }; 
 <div id="e1"> Div 1 </div> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM