admin管理员组文章数量:1387411
I am using SweetAlert2.0, This One
<script src=".min.js"></script>
it is working fine, but now I want to display table or div or HTML element in this sweet alert.
var swal_html='<div class="panel" style="background:aliceblue;font-weight:bold"><div class="panel-heading panel-info text-center btn-info"> <b>Import Status</b> </div> <div class="panel-body"><div class="text-center"><b><p style="font-weight:bold">Total number of not inserted rows : add data</p><p style="font-weight:bold">Row numbers:Add data</p></b></div></div></div>';
swal({title:"Good Job!", content: swal_html, icon: "success"});
I have tried the above code just for testing, but it's not working.
I have read the documentation of this sweet alert that says, use code mentioned below.
swal("Write something here:", {
content: "input",
})
.then((value) => {
swal(`You typed: ${value}`);
});
but I want to display table div etc.where should I write my code?
I am using SweetAlert2.0, This One
<script src="https://unpkg./sweetalert/dist/sweetalert.min.js"></script>
it is working fine, but now I want to display table or div or HTML element in this sweet alert.
var swal_html='<div class="panel" style="background:aliceblue;font-weight:bold"><div class="panel-heading panel-info text-center btn-info"> <b>Import Status</b> </div> <div class="panel-body"><div class="text-center"><b><p style="font-weight:bold">Total number of not inserted rows : add data</p><p style="font-weight:bold">Row numbers:Add data</p></b></div></div></div>';
swal({title:"Good Job!", content: swal_html, icon: "success"});
I have tried the above code just for testing, but it's not working.
I have read the documentation of this sweet alert that says, use code mentioned below.
swal("Write something here:", {
content: "input",
})
.then((value) => {
swal(`You typed: ${value}`);
});
but I want to display table div etc.where should I write my code?
Share Improve this question asked May 10, 2018 at 11:48 sayyed tabrezsayyed tabrez 1261 gold badge1 silver badge11 bronze badges2 Answers
Reset to default 1I think problem on your version. Include the latest version from CDN here:
<script src="https://unpkg./[email protected]/dist/sweetalert2.all.js"></script>
Also put HTML as a html:
property not content
, like following:
var swal_html = '<div class="panel" style="background:aliceblue;font-weight:bold"><div class="panel-heading panel-info text-center btn-info"> <b>Import Status</b> </div> <div class="panel-body"><div class="text-center"><b><p style="font-weight:bold">Total number of not inserted rows : add data</p><p style="font-weight:bold">Row numbers:Add data</p></b></div></div></div>';
swal({title:"Good Job!", html: swal_html});
try this
swal({
html: `<table id="table" border=1>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Salary</th>
<th>Country</th>
<th>City</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Dakota Rice</td>
<td>$36,738</td>
<td>Niger</td>
<td>Oud-Turnhout</td>
</tr>
<tr>
<td>2</td>
<td>Minerva Hooper</td>
<td>$23,789</td>
<td>Curaçao</td>
<td>Sinaai-Waas</td>
</tr>
<tr>
<td>3</td>
<td>Sage Rodriguez</td>
<td>$56,142</td>
<td>Netherlands</td>
<td>Baileux</td>
</tr>
<tr>
<td>4</td>
<td>Philip Chaney</td>
<td>$38,735</td>
<td>Korea, South</td>
<td>Overland Park</td>
</tr>
</tbody>
</table>`
})
本文标签: javascriptdisplay table or html SweetAlert 20Stack Overflow
版权声明:本文标题:javascript - display table or html SweetAlert 2.0 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744523841a2610621.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论