Javascript Bootbox模态don';正确格式化HTML
我正在使用bootbox作为我网站的弹出模式。调用下面的函数时,我想显示一个包含一些信息的小表格Javascript Bootbox模态don';正确格式化HTML,javascript,html,Javascript,Html,我正在使用bootbox作为我网站的弹出模式。调用下面的函数时,我想显示一个包含一些信息的小表格 function infoModal(){ var table = "<div>" + "<table class='formattedTable'>" + "<thead>" + "<tr>Legend</tr>" + "</thead>" + "<tbody>" + "<tr class='catS
function infoModal(){
var table = "<div>" + "<table class='formattedTable'>" + "<thead>" + "<tr>Legend</tr>" + "</thead>" + "<tbody>" + "<tr class='catString'>This color is the first color.</tr>" + "<tr class='warn'>This color is the second color.</tr>" + "<tr class='caution'>This color is the third color.</tr>" + "<tr class='danger'>This color is the fourth color.</tr>" + "</tbody>" + "</table>" +"</div>";
bootbox.confirm({
message: table,
buttons: {
confirm: {
label: 'OK'
}
},
callback: function (result) {
if (result) {
console.log("Thanks for using this modal!");
}
}
});
}
函数infoModal(){
var table=“”+”+“+”+“+”图例“+”+“+”此颜色是第一种颜色“+”此颜色是第二种颜色“+”此颜色是第三种颜色“+”此颜色是第四种颜色“+”+”;
bootbox.confirm({
信息:表,
按钮:{
确认:{
标签:“OK”
}
},
回调:函数(结果){
如果(结果){
log(“感谢您使用此模式!”);
}
}
});
}
但是,当我在HTML中测试时,它的格式如下:
<div class="bootbox-body">
<div>LegendThis color is the first color.This color is the second color.This color is the third color.This color is the fourth color.
<table class="formattedTable">
<thead><tr></tr></thead>
<tbody>
<tr class="catString"></tr>
<tr class="warn"></tr>
<tr class="caution"></tr>
<tr class="danger"></tr>
</tbody>
</table>
</div>
</div>
Legend此颜色是第一种颜色。此颜色是第二种颜色。此颜色是第三种颜色。此颜色是第四种颜色。
我知道我没有把div(减去引导框主体
div)像那样放在上面的表
变量中,所以这里发生了什么事?刚刚弄明白了——我忘记了进入每行的
标记!函数应该是这样的:
function infoModal(){
var table = "<div>" + "<table class='formattedTable'>" + "<thead>" + "<tr><td>Legend</td></tr>" + "</thead>" + "<tbody>" + "<tr class='catString'><td>This color is the first color.</td></tr>" + "<tr class='warn'><td>This color is the second color.</td></tr>" + "<tr class='caution'><td>This color is the third color.</td></tr>" + "<tr class='danger'><td>This color is the fourth color./<td></tr>" + "</tbody>" + "</table>" +"</div>";
bootbox.confirm({
message: table,
buttons: {
confirm: {
label: 'OK'
}
},
callback: function (result) {
if (result) {
console.log("Thanks for using this modal!");
}
}
});
}
函数infoModal(){
var table=“”+”+“+”+“+”图例“+”+“+”此颜色是第一种颜色“+”此颜色是第二种颜色“+”此颜色是第三种颜色“+”此颜色是第四种颜色。/“+”+”+”;
bootbox.confirm({
信息:表,
按钮:{
确认:{
标签:“OK”
}
},
回调:函数(结果){
如果(结果){
log(“感谢您使用此模式!”);
}
}
});
}
你忘记了td
的箍环,你完全正确!谢谢