简体   繁体   中英

Javascript: unterminated string literal

Something weird and I don't understand.

My code:

$("#loadbtn").click(function(e) {
    $html = '<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script> dsfdsf';
    $("#content").html($html);
});

When I run the page on browser, it returns error saying SyntaxError: unterminated string literal . I can't see anything wrong. Can you tell me what's wrong there?

Thank you.

</script>总是在javascript中引发奇怪的错误,因为它实际上关闭了当前脚本,即使在字符串中,也要尝试将其拆分

$html = '<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></scr'+'ipt> dsfdsf';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM