I'm trying to append a jQuery script with src attributes in my head tag when the window size is less of 580px.
I try with this code:
<script>
$(document).ready(function(){
var windowSize = $(window).width();
if( windowSize > 300 && windowSize < 570) {
$('head').append('<script src=\"http://code.jquery.com/jquery-1.11.3.min.js\" type="text/javascript\"><\/script>');
}
});
</script>
But it seems it doesn't work. Instead, I put inside the script a simple alert and it works:
<script>
$(document).ready(function(){
var windowSize = $(window).width();
if( windowSize > 300 && windowSize < 570) {
$('head').append('<script>alert("hi");<\/script>');
}
});
</script>
I think the problem is the src="". What am I supposed to do?