![](/img/trans.png)
[英]Apply jQuery to body (background) but not Modal using Bootstrap
[英]How to add paragraph to Bootstrap Modal body using JQuery?
单击按钮后,我想用一些数据更新 Bootstrap 模态正文,但我无法向其中添加任何内容。
我尝试使用$("#queueN").append(`<p class="boardNumber">Hi</p>`);
和$("#queueN").after("<p>Test</p>");
和document.getElementById("queueN").innerHTML = "<p>some text</p>";
但这些都没有更新我的模式。 有谁知道如何正确添加
到模态体?
<div
class="modal fade"
id="modal"
tabindex="-1"
role="dialog"
aria-labelledby="ModalLabel"
aria-hidden="true"
>
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">
Sėkmingai užsiregistravote!
</h5>
<button
type="button"
class="close"
data-dismiss="modal"
aria-label="Close"
>
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div id="queueN"></div>
</div>
<div class="modal-footer">
<a
class="btn btn-dark"
href="./puslapiai/svieslente.html"
role="button"
>Uždaryti</a
>
</div>
</div>
</div>
</div>
$("#register").click(function() {
if (document.getElementById("odontologas").checked) {
data.Odontologas.push({
KlientoNr: clientId(),
EilėsNr: queueN(data.Odontologas),
Būsena: "Eilėje",
AptarnavimoLaikas: "00:00"
});
console.log(data);
$(window).load(function() {
$("#modal").modal("show");
$("#queueN").append(`<p class="boardNumber">Hi</p>`);
});
// $("#queueN").after("<p>Test</p>");
// document.getElementById("queueN").innerHTML = "<p>some text</p>";
}
摆脱$(window).load()
。 这是一种不推荐使用的方法,并且在单击处理程序中不需要,因为该页面已经加载以应用单击侦听器。
此外,window 加载事件仅在页面生命周期中触发一次,并且与使用$(document).ready()
不同,后者在文档加载后的任何时候调用它都会触发
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.