第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何在屏幕上顯示輸入值?

如何在屏幕上顯示輸入值?

慕斯709654 2021-08-20 19:34:54
我一直無(wú)法顯示輸入值。它顯示未定義的標(biāo)題和作者,并在我指定數(shù)字時(shí)完全忽略頁(yè)面。鏈接 JS 小提琴:https : //jsfiddle.net/u3cb96x5/這是我嘗試過(guò)的 - 我創(chuàng)建了一個(gè)名為 addBookToLibrary 的函數(shù)來(lái)查詢 DOM 值并創(chuàng)建新的 Book 對(duì)象,但由于函數(shù)范圍,我將無(wú)法訪問(wèn)這些變量。// Variablesconst addBook = document.querySelector("#add");// const remove = document.querySelector("#remove");let library = [];// Event ListenersaddBook.addEventListener("click", render);class Book {    constructor(title, author, pages, isRead) {        this.title = title;        this.author = author;        this.pages = pages;        this.isRead = isRead;    }}function addBookToLibrary() {    let authorOfBook = document.querySelector("#author").value;    let bookTitle = document.querySelector("#book-title").value;    let numberOfPages = document.querySelector("#pages").value;    let status = document.querySelector("#isRead").value;    let newBook = new Book(bookTitle, authorOfBook, numberOfPages, status);    library.push(newBook);}function render() {    addBookToLibrary();    let table = document.querySelector("table");    let tr = document.createElement("tr");    table.appendChild(tr);    tr.innerHTML = `<td>${this.title}</td>                    <td>${this.author}</td>                    <td>${this.pages}</td>                    <td><button class="table-buttons" id="not-read">Not Read</button></td>                    <td><button class="table-buttons" id="remove">Delete</button></td>`;}我希望它顯示未定義的指定輸入字段的值
查看完整描述

3 回答

?
BIG陽(yáng)

TA貢獻(xiàn)1859條經(jīng)驗(yàn) 獲得超6個(gè)贊

使用數(shù)組而不是“this”


let book = library[library.length - 1];

<td>${book.title}</td>


查看完整回答
反對(duì) 回復(fù) 2021-08-20
  • 3 回答
  • 0 關(guān)注
  • 170 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)