0

我得到了这个 html 表

<table id="item-list" class="table table-hover table-striped">
    <thead>
        <tr>
            <th>Item</th>
            <th width="20%">Nombre</th>
            <th width="20%">Prix (TTC)</th>
            <th width="20%" class="actions">Total</th>
            <th></th>
        </tr>
    </thead>
    <tbody>
        <tr class="order-item">
            <td><input name="name[1]" type="hidden" class="m-wrap small refrech-calc" value="cardv2">cardv2</td>
            <td><input name="number[1]" type="text" class="m-wrap small refrech-calc" value="15"></td>
            <td><input name="price[1]" type="text" class="m-wrap small refrech-calc" value="42"></td>
            <td><span class="order-amount">630.00</span> €&lt;/td>
            <td><button class="btn red mini deleteRowButton"><i class="icon-remove icon-white"></i></button></td>
        </tr>
        <tr class="order-item">
            <td><input name="name[2]" type="hidden" class="refrech-calc" value="cardv2-5">cardv2-5</td>
            <td><input name="number[2]" type="text" class="refrech-calc" value="20"></td>
            <td><input name="price[2]" type="text" class="refrech-calc" value="45"></td>
            <td><span class="order-amount">900.00</span> €&lt;/td>
        </tr>
        <tr class="order-item">
            <td><input name="name[3]" type="hidden" class="refrech-calc" value="asuspx800">Asus px800</td>
            <td><input name="number[3]" type="text" class="refrech-calc" value="1"></td>
            <td><input name="price[3]" type="text" class="refrech-calc" value="260"></td>
            <td><span class="order-amount">260.00</span> €&lt;/td>
            <td><button class="btn red mini deleteRowButton"><i class="icon-remove icon-white"></i></button></td>
        </tr>
    </tbody>
</table>

我想生成另一个表,没有输入,但有它们的值。例子:

<table id="item-list" class="table table-hover table-striped">
    ...
    <tbody>
        <tr class="order-item">
            <td>(name[1] values)</td>
            <td>(number[1])</td>
            <td>price[1]</td>
            <td><span class="order-amount">630.00</span> €&lt;/td>
        </tr>
        <tr class="order-item">
            <td>name[2]</td>
            <td>number[2]</td>
            <td>price[2]</td>
            <td><span class="order-amount">900.00</span> €&lt;/td>
        </tr>
        ....etc
    </tbody>
</table>

事实上,我想在另一个“干净”表中总结我的输入值。

我的问题是获得正确的输入数组并显示所有这些。

4

1 回答 1

0

尝试这样的事情,小提琴

        $(function(){
            var clone_table = $('#item-list').clone();
            $(clone_table).addClass('cloneKlass');

            $('body').append(clone_table);

            $('.cloneKlass input').each(function(){
                $(this).replaceWith(this.value);
            })
        })
于 2013-10-21T12:04:19.633 回答