简体   繁体   中英

javascript quotation issue. Chrome gives syntax error?

I have following line in my javascript:

$tasksContainer.append(html + "<label><input type="checkbox" class="js-task" data-index="" + index + "" data-task-selected="false">" + tasks[task].taskName + "</label></div>");

Chrome console says: 'TaskView.js:118 Uncaught SyntaxError: missing ) after argument list'

Change the double quotes around a fixed string to single quotes.

'Hello "World"!'

您可以在双引号内使用单引号:

$tasksContainer.append(html + "<label><input type='checkbox' class='js-task' data-index='" + index + "' data-task-selected='false'>" + tasks[task].taskName + "</label></div>");

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