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

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

如何更改屬于 JS/jQuery 中特定行的按鈕文本?

如何更改屬于 JS/jQuery 中特定行的按鈕文本?

PHP
翻閱古今 2021-08-21 10:05:16
我正在處理如下所示的html/php 代碼,其中單擊按鈕時,我想將Go按鈕文本更改為Converting。<?php  foreach ($programs as $key => $program) {  ?>    <tr data-index="<?php echo $key; ?>">      <td><input style="text-align:center; width:90px;"  onclick="change()" type="submit"  id="go-btn" name="go-button" value="Go" data-id="<?php echo $key; ?>" ></input></td>   </tr><?php }?>此時,我在 UI 上有 2 行。下面是inspect的代碼:<tr data-index="0">   <td><input onclick="change()" type="submit" id="go-btn" name="go-button" value="Go" data-id="0" class="go-btn btn btn-outline-primary">   </td></tr><tr data-index="1">   <td><input onclick="change()" type="submit" id="go-btn" name="go-button" value="Go" data-id="1" class="go-btn btn btn-outline-primary">   </td></tr>這是我嘗試過的,但還需要做更多的工作。 function change() {    var elem = document.getElementById("go-btn");    var attribute = elem.getAttribute('data-id');    console.log(attribute);  // It will print 0 everytime as it is taking the data-id value in the document. } 問題陳述:我想知道我應該在上面的JS 代碼中進行哪些更改,以便在單擊按鈕時,屬于特定行的按鈕內的文本應該從Go更改為Converting。
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 169 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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