How To Get JavaScript Script Tags Inside JQuery .html() Function?
Is it possible to get JavaScript script tags inside jQuery .html() function? function pleaseWork(){ $('#content').html('This is the header
This is the header
Solution 1:
Escape the </script>
tag, by replacing it with this: <\/script>
If that doesn't work, also surround the script with cdata tags.
Working demo: http://jsfiddle.net/BgxZN/1/
EDIT:
If you want to actually show the contents of the javascript file inside the div, you'll need to use an XMLHTTP request or an iframe.
New working demo: http://jsfiddle.net/BgxZN/13/
Escape the </script>
tag, by replacing it with this: <\/script>
If that doesn't work, also surround the script with cdata tags.
Working demo: http://jsfiddle.net/BgxZN/1/
EDIT:
If you want to actually show the contents of the javascript file inside the div, you'll need to use an XMLHTTP request or an iframe.
New working demo: http://jsfiddle.net/BgxZN/13/
Post a Comment for "How To Get JavaScript Script Tags Inside JQuery .html() Function?"