如图,有1个一口价,然后报名价需要设置为一口价的5折。如何写代码来实现批量填充的目的。(强烈鄙视无良开发商,上面那个批量填充是填充固定数值的。)附上框架内的网页代码:
<div class="next-table" style="text-align: center;"><div class="next-table-inner"><div class="next-table-header">
<div class="next-table-header-inner"><table><colgroup><col style="width: 60px;"><col style="width: 60px;"><col style="width: 60px;"><col style="width: 60px;"><col style="width: 100px;"><col style="width: 100px;"><col style="width: 60px;"><col style="width: 100px;"><col style="width: 60px;"><col style="width: 100px;"><col style="width: 60px;"></colgroup><tbody><tr><th rowspan="1" class="next-table-header-node first"><div class="next-table-cell-wrapper"><!-- react-text: 263 -->尺寸<!-- /react-text --></div></th><th rowspan="1" class="next-table-header-node"><div class="next-table-cell-wrapper"><!-- react-text: 266 -->外框类型<!-- /react-text --></div></th><th rowspan="1" class="next-table-header-node"><div class="next-table-cell-wrapper"><!-- react-text: 269 -->颜色分类<!-- /react-text --></div></th><th rowspan="1" class="next-table-header-node"><div class="next-table-cell-wrapper"><!-- react-text: 272 -->组合形式<!-- /react-text --></div></th><th rowspan="1" class="next-table-header-node"><div class="next-table-cell-wrapper"><!-- react-text: 275 -->店铺一口价(元)<!-- /react-text --></div></th><th rowspan="1" class="next-table-header-node"><div class="next-table-cell-wrapper"><!-- react-text: 278 -->折扣率<!-- /react-text --></div></th><th rowspan="1" class="next-table-header-node sign-price"><div class="next-table-cell-wrapper"><!-- react-empty: 281 --><div><span style="color:red">*</span>报名价(元)</div><span><a style="font-weight: lighter; font-size: 12px;">批量设置</a></span></div></th><th rowspan="1" class="next-table-header-node"><div class="next-table-cell-wrapper"><!-- react-text: 287 -->审核通过价<!-- /react-text --></div></th><th rowspan="1" class="next-table-header-node"><div class="next-table-cell-wrapper"><!-- react-text: 290 -->当前库存<!-- /react-text --></div></th><th rowspan="1" class="next-table-header-node"><div class="next-table-cell-wrapper"><div><span style="color: rgb(221, 39, 39);">*</span><span>报名库存</span></div><!-- react-empty: 330 --></div></th><th rowspan="1" class="next-table-header-node last"><div class="next-table-cell-wrapper"><!-- react-text: 300 -->操作<!-- /react-text --></div></th></tr></tbody></table></div></div><div class="next-table-body"><table><colgroup><col style="width: 60px;"><col style="width: 60px;"><col style="width: 60px;"><col style="width: 60px;"><col style="width: 100px;"><col style="width: 100px;"><col style="width: 60px;"><col style="width: 100px;"><col style="width: 60px;"><col style="width: 100px;"><col style="width: 60px;"></colgroup><tbody><tr class="next-table-row first"><td class="next-table-cell first" colspan="1" rowspan="1"><div class="next-table-cell-wrapper"><!-- react-text: 9526 -->30x42cm细铝框<!-- /react-text --></div></td><td class="next-table-cell" colspan="1" rowspan="1"><div class="next-table-cell-wrapper"><!-- react-text: 9529 -->黑色<!-- /react-text --></div></td><td class="next-table-cell" colspan="1" rowspan="1"><div class="next-table-cell-wrapper"><!-- react-text: 9532 -->HS02725一套两幅更优惠,画面如图<!-- /react-text --></div></td><td class="next-table-cell" colspan="1" rowspan="1"><div class="next-table-cell-wrapper"><!-- react-text: 9535 -->单幅价格,不带有机玻璃<!-- /react-text --></div></td><td class="next-table-cell" data-spm-anchor-id="a21xr.9711186.stock_presale_item.i11.28ae3465ZXiSmc"><div class="next-table-cell-wrapper"><!-- react-text: 9538 -->274.0<!-- /react-text --></div></td><td class="next-table-cell" data-spm-anchor-id="a21xr.9711186.stock_presale_item.i12.28ae3465ZXiSmc"><div class="next-table-cell-wrapper"><span>/</span></div></td><td class="sign-price next-table-cell"><div class="next-table-cell-wrapper"><div class="next-form-item next-row tab-formitem" style="margin: 0px;"><div class="next-col-24 next-form-item-control"><span class="next-input next-input-single next-input-small" style="text-align: center;"><input type="text" data-meta="Field" id="activityPrice0-0-0-0" value="" data-initvalue="" height="100%"></span><!-- react-text: 9548 --> <!-- /react-text --><div class=""></div><!-- react-text: 9550 --> <!-- /react-text --></div></div></div></td><td class="next-table-cell"><div class="next-table-cell-wrapper"><!-- react-text: 9553 -->/<!-- /react-text --></div></td><td class="next-table-cell"><div class="next-table-cell-wrapper"><!-- react-text: 9556 -->999<!-- /react-text --></div></td><td class="next-table-cell"><div class="next-table-cell-wrapper"><!-- react-empty: 9559 --><span>共享库存</span></div></td><td class="next-table-cell last"><div class="next-table-cell-wrapper"><button type="button" class="next-btn next-btn-text next-btn-normal next-btn-medium action-button"><!-- react-text: 9564 -->取消报名<!-- /react-text --></button></div></td></tr><tr class="next-table-row"><td class="next-table-cell first" colspan="1" rowspan="1"><div class="next-table-cell-wrapper"><!-- react-text: 10302 -->42x60cm细铝框<!-- /react-text --></div></td><td class="next-table-cell" colspan="1" rowspan="1"><div class="next-table-cell-wrapper"><!-- react-text: 10305 -->黑色<!-- /react-text --></div></td><td class="next-table-cell" colspan="1" rowspan="1"><div class="next-table-cell-wrapper"><!-- react-text: 10308 -->HS02725一套两幅更优惠,画面如图<!-- /react-text --></div></td><td class="next-table-cell" colspan="1" rowspan="1"><div class="next-table-cell-wrapper"><!-- react-text: 10311 -->单幅价格,不带有机玻璃<!-- /react-text --></div></td><td class="next-table-cell"><div class="next-table-cell-wrapper"><!-- react-text: 10314 -->414.0<!-- /react-text --></div></td><td class="next-table-cell"><div class="next-table-cell-wrapper"><span>/</span></div></td><td class="sign-price next-table-cell"><div class="next-table-cell-wrapper"><div class="next-form-item next-row tab-formitem" style="margin: 0px;"><div class="next-col-24 next-form-item-control"><span class="next-input next-input-single next-input-small" style="text-align: center;"><input type="text" data-meta="Field" id="activityPrice1-0-0-0" value="" data-initvalue="" height="100%"></span><!-- react-text: 10324 --> <!-- /react-text --><div class=""></div><!-- react-text: 10326 --> <!-- /react-text --></div></div></div></td><td class="next-table-cell"><div class="next-table-cell-wrapper"><!-- react-text: 10329 -->/<!-- /react-text --></div></td><td class="next-table-cell"><div class="next-table-cell-wrapper"><!-- react-text: 10332 -->997<!-- /react-text --></div></td><td class="next-table-cell"><div class="next-table-cell-wrapper"><!-- react-empty: 10335 --><span>共享库存</span></div></td><td class="next-table-cell last"><div class="next-table-cell-wrapper"><button type="button" class="next-btn next-btn-text next-btn-normal next-btn-medium action-button"><!-- react-text: 10340 -->取消报名<!-- /react-text --></button></div></td></tr><tr class="next-table-row"><td class="next-table-cell first" colspan="1" rowspan="1"><div class="next-table-cell-wrapper"><!-- react-text: 10343 -->50x70cm细铝框<!-- /react-text --></div></td><td class="next-table-cell" colspan="1" rowspan="1"><div class="next-table-cell-wrapper"><!-- react-text: 10346 -->黑色<!-- /react-text --></div></td><td class="next-table-cell" colspan="1" rowspan="1"><div class="next-table-cell-wrapper"><!-- react-text: 10349 -->HS02725一套两幅更优惠,画面如图<!-- /react-text --></div></td><td class="next-table-cell" colspan="1" rowspan="1"><div class="next-table-cell-wrapper"><!-- react-text: 10352 -->单幅价格,不带有机玻璃<!-- /react-text --></div></td><td class="next-table-cell"><div class="next-table-cell-wrapper"><!-- react-text: 10355 -->474.0<!-- /react-text --></div></td><td class="next-table-cell"><div class="next-table-cell-wrapper"><span>/</span></div></td><td class="sign-price next-table-cell"><div class="next-table-cell-wrapper"><div class="next-form-item next-row tab-formitem" style="margin: 0px;"><div class="next-col-24 next-form-item-control"><span class="next-input next-input-single next-input-small" style="text-align: center;"><input type="text" data-meta="Field" id="activityPrice2-0-0-0" value="" data-initvalue="" height="100%"></span><!-- react-text: 10365 --> <!-- /react-text --><div class=""></div><!-- react-text: 10367 --> <!-- /react-text --></div></div></div></td><td class="next-table-cell"><div class="next-table-cell-wrapper"><!-- react-text: 10370 -->/<!-- /react-text --></div></td><td class="next-table-cell"><div class="next-table-cell-wrapper"><!-- react-text: 10373 -->990<!-- /react-text --></div></td><td class="next-table-cell"><div class="next-table-cell-wrapper"><!-- react-empty: 10376 --><span>共享库存</span></div></td><td class="next-table-cell last"><div class="next-table-cell-wrapper"><button type="button" class="next-btn next-btn-text next-btn-normal next-btn-medium action-button"><!-- react-text: 10381 -->取消报名<!-- /react-text --></button></div></td></tr><tr class="next-table-row last"><td class="next-table-cell first" colspan="1" rowspan="1"><div class="next-table-cell-wrapper"><!-- react-text: 10384 -->60x80cm细铝框<!-- /react-text --></div></td><td class="next-table-cell" colspan="1" rowspan="1"><div class="next-table-cell-wrapper"><!-- react-text: 10387 -->黑色<!-- /react-text --></div></td><td class="next-table-cell" colspan="1" rowspan="1"><div class="next-table-cell-wrapper"><!-- react-text: 10390 -->HS02725一套两幅更优惠,画面如图<!-- /react-text --></div></td><td class="next-table-cell" colspan="1" rowspan="1"><div class="next-table-cell-wrapper"><!-- react-text: 10393 -->单幅价格,不带有机玻璃<!-- /react-text --></div></td><td class="next-table-cell"><div class="next-table-cell-wrapper"><!-- react-text: 10396 -->614.0<!-- /react-text --></div></td><td class="next-table-cell"><div class="next-table-cell-wrapper"><span>/</span></div></td><td class="sign-price next-table-cell"><div class="next-table-cell-wrapper"><div class="next-form-item next-row tab-formitem" style="margin: 0px;

解决方案 »

  1.   

    给你来个例子<html>
    <head>
      <style>
        .flexBox {
      display: flex;
      display: -webkit-flex;
      flex-direction: column;
      flex-wrap: nowrap;
      justify-content: center;
      align-items: center;
    }
    .boxItem {
      width: 300px;
      height: 200px;
      border: 1px solid #ddd;
    }
      </style>
      <script type="text/javascript" src="jquery-1.9.1.js"></script>
    </head>
    <body>  <table border=1 id="tbl">
        <thead>
      <tr>
        <th>Price1</th>
    <th>Price2 <a href="#" id="btnSetPrice">设置</a></th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span name="price1">12.34</span></td>
    <td><input name="price2"></td>
      </tr>
      <tr>
        <td><span name="price1">16.14</span></td>
    <td><input name="price2"></td>
      </tr>
      <tr>
        <td><span name="price1">11.24</span></td>
    <td><input name="price2"></td>
      </tr>
    </tbody>
      </table>
    </body>
    </html><script>
    $(function(){
    var btnSetPrice = $('#btnSetPrice');
    var tblName = $('#tbl');
    btnSetPrice.on('click', function() {
    setPrice();
    });

    function setPrice() {
    var tr = tblName.find('tbody tr');
    $.each(tr, function() {
    var value = parseFloat($(this).find('span[name="price1"]').text());
    $(this).find('input[name=price2]').val(value / 2);
    });
    }
    })
    </script>