I have a div that contains some html and a lot of Javascript
<div id="mydiv">
<p>Hello Philippines</p> my first time in Philippines is nice
<script type="text/javascript">alert("how was it became nice?");</script>
well I experienced a lot of things
<script type="text/javascript">alert("and how about your Japan's trip?");</script>
well its more nicer ^^ but both countries are good! hahah
</div>
I want to put the non-Javascript code and Javascript code in two separate variables:
var html = $("#mydiv").html();
My problem here is that my javascript is executing, which makes me stop to create the code I want which is the storing of javascript and non-javascript to two different variables.
- how can I stop the javascript codes from executing when they are get inside the div?
- how can I store the javascript and non-javascript code into two different variables safely?
NOTE: I need the stored javascript for later execution
textinstead ofhtml, 2) you probably need some regex to separate them