亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

表格行的編輯/保存按鈕的可見性問題 (JS)

表格行的編輯/保存按鈕的可見性問題 (JS)

青春有我 2023-04-01 15:16:42
您好,我正在嘗試為預算跟蹤應用程序構建一個包含輸入的表格。我在 JS 上遇到了一些麻煩。本質上,我希望用戶能夠添加、編輯和保存行。我只希望保存或編輯按鈕一次可見。這在編輯并保存一行后有效,但默認情況下它會顯示所有按鈕。同樣,在編輯一行之后,按鈕不再排成一行,而是堆疊在彼此之上。任何幫助將非常感激。這是我第一次使用 JS。我的代碼<div>  <!-- ... -->  <div class="five">    <h1>Transactions</h1>    <div class="txlist">      <table cellspacing="0" cellpadding="0" border="0" width="1500">        <thead>          <th>Date</th>          <th>Account</th>          <th>Category</th>          <th>Amount</th>          <th></th>        </thead>        <tbody class="txlist" id="data_table">          <tr id="addtx">            <td><input type="date" id="new_date" placeholder="Date"></td>            <td><input type="text" id="new_account" placeholder="Account"></td>            <td><input type="text" id="new_category" placeholder="Category"></td>            <td><input type="text" id="new_amount" placeholder="Amount"></td>            <td>              <input type="button" id="save_button3" value="Save" class="save" onclick="add_row();">              <input type="button" value="??" class="delete" onclick="nonew()">            </td>          </tr>          <tr id="row1">            <td id="date_row1">24.08.2020</td>            <td id="account_row1">Credit Card</td>            <td id="category_row1">Expense: Restaurants</td>            <td id="amount_row1">- $32.45</td>            <td>              <input type="button" id="edit_button1" value="Edit" class="edt" onclick="edit_row('1')">              <input type="button" id="save_button1" value="Save" class="save" onclick="save_row('1')">              <input type="button" value="??" class="delete" onclick="delete_row('1')">            </td>          </tr>
查看完整描述

2 回答

?
慕容森

TA貢獻1853條經驗 獲得超18個贊

我認為有更好的方法可以實現這一點,但同樣,您的問題是在保存和編輯時您正在將按鈕的 style.display 屬性更改為

document.getElementById("edit_button"+no).style.display="block";

你需要保留

document.getElementById("edit_button"+no).style.display="inline-block";


查看完整回答
反對 回復 2023-04-01
?
拉莫斯之舞

TA貢獻1820條經驗 獲得超10個贊

您共享的標記已損壞。我看到 2 個開始<table>標簽和 3 個結束</table>標簽。你能分享正確的標記或最少的工作代碼嗎?



查看完整回答
反對 回復 2023-04-01
  • 2 回答
  • 0 關注
  • 142 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號