[jQuery] adding $("<script>") node actually runs the script - correct behavior?
If I have a node that isn't in the DOM, and then I add a script to it,
then it is actually executed. Example
Expected behavior : s variable contains the string "<script>alert('hi')
</script>".
Observed behavior : alert box pop up and s contains ""
<script>
var s = $("<span/>").append($("<script/>").text("alert('hi')")).html()
<script>
You can see it running here : http://paulisageek.com/tmp/jquery-script.html
Am I doing something wrong? Can I not write javascript from within
jquery?