Executing [removed] elements inserted with [removed]

后端 未结 20 2541
囚心锁ツ
囚心锁ツ 2020-11-22 00:12

I\'ve got a script that inserts some content into an element using innerHTML.

The content could for example be:



        
20条回答
  •  难免孤独
    2020-11-22 01:08

    Try function eval().

    data.newScript = ''
    var element = document.getElementById('elementToRefresh');
    element.innerHTML = data.newScript;
    eval(element.firstChild.innerHTML);
    

    This is a real example from a project that i am developing. Thanks to this post

提交回复
热议问题