I have looked at the multiple methods of inserting HTML with javascript, both with jQuery .prepend and .innerHTML and I keep getting the same output no matter what I do:
'); }
I am trying to insert HTML if the screen resolution if of a certain width. These are the two scripts I have tried:
<script type="text/javascript" charset="utf-8" >
if (screen.width >= 500)
{
$('#stemanimation_hype_container').prepend('<script type="text/javascript" charset="utf-8" src="STEM%20Animation_Resources/stemanimation_hype_generated_script.js?58608></script>');
}
</script>
<div id="stemanimation_hype_container" style="position:relative;overflow:hidden;width:900px;height:300px;">
</div>
The other:
<script type="text/javascript" charset="utf-8" >
if (screen.width >= 500)
{
document.getElementById("stemanimation_hype_container").innerHTML='<script type="text/javascript" charset="utf-8" src="STEM%20Animation_Resources/stemanimation_hype_generated_script.js?58608'></script>";
}
</script>
<div id="stemanimation_hype_container" style="position:relative;overflow:hidden;width:900px;height:300px;">
</div>
Any idea what may be going on? I am testing this on a page with only jquery and no other scripts to ensure no conflicts. Thank you for any help you can give me!