SyntaxError:意外的令牌<

时间:2015-12-07 01:11:01

标签: javascript jquery

<script type="text/javascript">
function isIE () {
    var myNav = navigator.userAgent.toLowerCase();
    return (myNav.indexOf('msie') != -1) ? parseInt(myNav.split('msie')[1]) : false;
}

window.isIEOld = isIE() && isIE() < 9;
window.isiPad = navigator.userAgent.match(/iPad/i);

var img = $('.video').data('placeholder'),
    video = $('.video').data('video'),
    noVideo = $('.video').data('src'),
    el = '';

if($(window).width() > 599 && !isIEOld && !isiPad) {
    el +=   '<video autoplay loop poster="' + img + '">';
    el +=       '<source src="' + video + '" type="video/mp4">';
    el +=   '</video>';
} else {
    el = '<div class="video-element" style="background-image: url(' + noVideo + ')"></div>';
}

$('.video').prepend(el);
</script>

我收到此js错误但无法找出原因...它没有引用行号。我在Wordpress functions.php ...

中排队脚本

1 个答案:

答案 0 :(得分:3)

您的脚本标记不正确:

<script type="text/html">

应该是:

<script type="text/javascript">