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

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

統(tǒng)計(jì)動(dòng)態(tài)行數(shù)并顯示在html的輸入框中

統(tǒng)計(jì)動(dòng)態(tài)行數(shù)并顯示在html的輸入框中

夢里花落0921 2023-08-18 10:26:18
我試圖計(jì)算 html 表中的動(dòng)態(tài)行數(shù),其中在計(jì)算行數(shù)時(shí),它也在計(jì)算表頭,并且我想在輸入框中顯示行數(shù)。$(document).ready(function(){     $(".count").click(function(){                    // Select all the rows in the table         // and get the count of the selected elements         var rowCount = $("#tbpnr tr").length;         var x = document.write(rowCount*280).innerHTML;          return(x);        document.getElementById("answer").value = x;    }); });
查看完整描述

2 回答

?
一只斗牛犬

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

此代碼將計(jì)算表主體中的行數(shù),并將行數(shù) * 280 放入輸入元素中。


$(document).ready(function() {

  $(".count").click(function() {

    var rowCount = $("#tbpnr tr").length;

    document.getElementById("count").textContent = rowCount;

    document.getElementById("answer").value = rowCount * 280;

  });

});

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<table>

  <thead>

    <tr>

      <th></th>

      <th></th>

      <th></th>

      <th></th>

    </tr>

  </thead>

  <tbody id="tbpnr">

    <tr>

      <td></td>

      <td></td>

      <td></td>

      <td></td>

    </tr>

    <tr>

      <td></td>

      <td></td>

      <td></td>

      <td></td>

    </tr>

    <tr>

      <td></td>

      <td></td>

      <td></td>

      <td></td>

    </tr>

    <tr>

      <td></td>

      <td></td>

      <td></td>

      <td></td>

    </tr>

    <tr>

      <td></td>

      <td></td>

      <td></td>

      <td></td>

    </tr>

    <tr>

      <td></td>

      <td></td>

      <td></td>

      <td></td>

    </tr>

    <tr>

      <td></td>

      <td></td>

      <td></td>

      <td></td>

    </tr>

    <tr>

      <td></td>

      <td></td>

      <td></td>

      <td></td>

    </tr>

    <tr>

      <td></td>

      <td></td>

      <td></td>

      <td></td>

    </tr>

    <tr>

      <td></td>

      <td></td>

      <td></td>

      <td></td>

    </tr>

    <tr>

      <td></td>

      <td></td>

      <td></td>

      <td></td>

    </tr>

    <tr>

      <td></td>

      <td></td>

      <td></td>

      <td></td>

    </tr>

  </tbody>

</table>

<button class="count">Count</button>

<br>

Number of rows:

<b id="count"></b>

<br>

Number of rows * 280:

<input id="answer" />



查看完整回答
反對 回復(fù) 2023-08-18
?
縹緲止盈

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

您可以使用jQuery它本身來添加框中的計(jì)數(shù)input。嘗試使用下面的代碼來顯示內(nèi)部的計(jì)數(shù)input。


$(document).ready(function(){ 

    $(".count").click(function(){            

        // Select all the rows in the table 

        // and get the count of the selected elements 

        var rowCount = $("#tbpnr tr").length; 

        $("#answer").attr("value", rowCount*280)

    }); 

});

請?zhí)砑颖砀竦?HTML 以解決表格標(biāo)題計(jì)數(shù)問題。


查看完整回答
反對 回復(fù) 2023-08-18
  • 2 回答
  • 0 關(guān)注
  • 188 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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