目前我在侧面文本/ javascript中使用以下代码添加视图和删除按钮组。
jsonData.data[i][5] = '<div class="btn-group-justified" data-toggle="buttons"><a href="more_log.php?more=' + jsonData.data[i][0] +'"_blank" class="btn btn-success btn-sm">Add</a><a href="delete_well.php?delete='+ jsonData.data[i][0] +'"_blank" class="btn btn-danger btn-sm">Delete </a><a href="well_veiw.php?view=' + jsonData.data[i][0] +'"_blank" class="btn btn-info btn-sm">View</a></div>';
现在我想添加一个确认onclick反对删除
onclick="return confirm('Are you sure to delete this well and its associated logs...?')"
我试过这种方式,但没有工作
jsonData.data[i][5] = '<div class="btn-group-justified" data-toggle="buttons"><a href="more_log.php?more=' + jsonData.data[i][0] +'"_blank" class="btn btn-success btn-sm">Add</a><a href="delete_well.php?delete='+ jsonData.data[i][0] +'"_blank" onclick="return confirm('Are you sure to delete this well and its associated logs...?')" class="btn btn-danger btn-sm">Delete </a><a href="well_veiw.php?view=' + jsonData.data[i][0] +'"_blank" class="btn btn-info btn-sm">View</a></div>';
答案 0 :(得分:3)
在\
之前添加'
,因为您要在字符串中添加字符串。
jsonData.data[i][5] = '<div class="btn-group-justified" data-toggle="buttons"><a href="more_log.php?more=' + jsonData.data[i][0] +'"_blank" class="btn btn-success btn-sm">Add</a><a href="delete_well.php?delete='+ jsonData.data[i][0] +'"_blank" onclick="return confirm(\'Are you sure to delete this well and its associated logs...?\')" class="btn btn-danger btn-sm">Delete </a><a href="well_veiw.php?view=' + jsonData.data[i][0] +'"_blank" class="btn btn-info btn-sm">View</a></div>';