linting时未闭合的字符串错误

时间:2016-04-22 11:21:07

标签: javascript jquery

我已经使用以下代码继承了一个项目,我无法通过JSlint - 有人知道需要更改哪些内容吗?

如果我关闭第2行的字符串,则会获得预期'/',而是看到''

$this.append(
    '<a href="' + slideLink + '"' + slideTarget + '>
        <span class="slide-time-date"></span>
        <div class="slide-overlay-text slide-overlay-text-mobile"' + slideColour + '>
            <span>' + slideOverlaytext + '</span>
        </div>
        <div class="slide-overlay-text slide-overlay-text-tablet"' + slideColour + '>
            <span>' + slideOverlaytext + '</span>
        </div>
        <div class="slide-overlay-text slide-overlay-text-desktop"' + slideColour + '>
            <span>' + slideOverlaytext + '</span>
        </div>
        <img src="' + slideImg + '" alt="' + slideTitle + '" />
    </a>'
);

1 个答案:

答案 0 :(得分:0)

做这样的事情

$this.append(
            '<a href="' + slideLink + '"' + slideTarget + '>\
            <span class="slide-time-date"></span>\
            <div class="slide-overlay-text slide-overlay-text-mobile"' + slideColour + '>\
    <span>' + slideOverlaytext + '</span>\
    </div>\
    <div class="slide-overlay-text slide-overlay-text-tablet"' + slideColour + '>\
    <span>' + slideOverlaytext + '</span>\
    </div>\
    <div class="slide-overlay-text slide-overlay-text-desktop"' + slideColour + '>\
    <span>' + slideOverlaytext + '</span>\
    </div>\
    <img src="' + slideImg + '" alt="' + slideTitle + '" />\
            </a>'
    );