我可以知道我的代码有什么问题

时间:2021-08-05 19:38:20

please help me figure it out what is wrong with my code. i'm trying to append new row on my table with an id and a class. Here is my code

请帮我弄清楚我的代码有什么问题。我正试图在我的桌子上添加一个id和一个类的新行。这是我的代码

function hideDiv() {
    document.getElementById('addLayout').style.display = "none";
    $(".tb1_tb").append("<tr><td id="dropzone" ondrop="drop(event)" ondragover="allowDrop(event)"></td></tr>");
}

1 个解决方案

#1


There is error in append, you have to escape quotes inside quotes or use single quotes outside.

附加中有错误,您必须在引号内转义引号或在外部使用单引号。

function hideDiv() {
    document.getElementById('addLayout').style.display = "none";
    $(".tb1_tb").append('<tr><td id="dropzone" ondrop="drop(event)" ondragover="allowDrop(event)"></td></tr>');
}

OR

Escape the quotes by preceding them by \

通过前面的\来逃避引号

$(".tb1_tb").append("<tr><td id=\"dropzone\" ondrop=\"drop(event)\" ondragover=\"allowDrop(event)\"></td></tr>");

#1


There is error in append, you have to escape quotes inside quotes or use single quotes outside.

附加中有错误,您必须在引号内转义引号或在外部使用单引号。

function hideDiv() {
    document.getElementById('addLayout').style.display = "none";
    $(".tb1_tb").append('<tr><td id="dropzone" ondrop="drop(event)" ondragover="allowDrop(event)"></td></tr>');
}

OR

Escape the quotes by preceding them by \

通过前面的\来逃避引号

$(".tb1_tb").append("<tr><td id=\"dropzone\" ondrop=\"drop(event)\" ondragover=\"allowDrop(event)\"></td></tr>");