[英]How do I get specific data from my localstorage so I can show them in a modal in JavaScript?
[英]How do I append elements to my bootstrap modal to display data from localstorage?
我需要向我的引導模式添加元素,以便每次打開它時我都可以從我的本地存儲中看到一些數據,這就是我目前所擁有的。 我現在只是想 append fn 元素
JS:
function doSomething(e, student){
let fn = document.createElement("h5");
let ln = document.createElement("h5");
if (e.target !== e.currentTarget){
var clickedItem = e.target.id;
for(student of data){
if (clickedItem == student.id)
fn.innerHTML = (student.firstN);
ln.innerHTML = (student.lastN);
$('#infoModal modbod').append(fn);
$('#infoModal').modal('show');
}
}
這是模態的 HTML 代碼
<div class="modal fade" id="infoModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h2 class="modal-title" id="exampleModalLabel">Student Info</h2>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body" id="modbod">
<div class="test" id="testdiv">
</div>
<!-- <div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div> -->
</div>
</div>
</div>
</div>
您在modbod
之前錯過了#
。
像這樣修復它:
$('#infoModal #modbod').append(fn);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.