-2

テーブルがあり、テーブル内の div を取得しようとしています (クラス別: product_li)。それらを「upsell」という名前の別の div 要素に配置しようとしています。どうすればいいですか?私のテーブルは次のようになります。

<table cellspacing="0" class="productTable"><tr><td id="catProdTd_6732684" class="productItem"><div class="product_li item-on-sale-0 aaronBell hide">
    <div class="grid_3">
        <img class="sale-0" src="/images/sale.png" />
        <div class="prev">
            <a href="/store/prints/gold-snake-and-skull"><img id="catsproduct_6732684" src="/images/Artists/Aaron-Bell/777.jpg" alt="Gold Snake and Skull" border="0" /></a>
        </div><!-- .prev -->
    </div><!-- .grid_3 -->

    <div class="grid_4">
        <div class="entry_content">
            <a href="/store/prints/gold-snake-and-skull"><h3 class="title">Gold Snake and Skull</h3></a>

            <p>Dimensions 12x15"<br />High Dynamic Range (HDR) Pigments<br />Printed on 100% Cotton Rag</p>

<span class="favorite-link">#6732684#<a class="favoritelink" href="/FavoriteProcess.aspx?OID=6732684&amp;OTYPE=27">[+] favorites</a></span> | <a class="more" href="/store/prints/gold-snake-and-skull">Learn More</a>

        </div><!-- .entry_content -->
    </div><!-- .grid_4 -->

    <div class="grid_2">
        <div class="cart">
            <div class="price">
                <div class="price_new">$39.95</div>
                <div class="price_old">$59.95</div>
            </div>
            <span class="btn-buy"><input class="productSubmitInput" name="AddToCart_Submit" type="submit" value="Buy Now" onclick="AddToCart(208719,6732684,'',3,'','',true);return false;" /></span>
        </div><!-- .cart -->
    </div><!-- .grid_2 -->

    <div class="clear"></div>
</div></td><td id="catProdTd_6732685" class="productItem"><div class="product_li item-on-sale-0 aaronBell hide">
    <div class="grid_3">
        <img class="sale-0" src="/images/sale.png" />
        <div class="prev">
            <a href="/store/prints/namakubi"><img id="catsproduct_6732685" src="/images/Artists/Aaron-Bell/500.jpg" alt="Namakubi" border="0" /></a>
        </div><!-- .prev -->
    </div><!-- .grid_3 -->

    <div class="grid_4">
        <div class="entry_content">
            <a href="/store/prints/namakubi"><h3 class="title">Namakubi</h3></a>

            <p>Dimensions 12x15"<br />High Dynamic Range (HDR) Pigments<br />Printed on 100% Cotton Rag</p>

<span class="favorite-link">#6732685#<a class="favoritelink" href="/FavoriteProcess.aspx?OID=6732685&amp;OTYPE=27">[+] favorites</a></span> | <a class="more" href="/store/prints/namakubi">Learn More</a>

        </div><!-- .entry_content -->
    </div><!-- .grid_4 -->

    <div class="grid_2">
        <div class="cart">
            <div class="price">
                <div class="price_new">$39.95</div>
                <div class="price_old">$59.95</div>
            </div>
            <span class="btn-buy"><input class="productSubmitInput" name="AddToCart_Submit" type="submit" value="Buy Now" onclick="AddToCart(208719,6732685,'',3,'','',true);return false;" /></span>
        </div><!-- .cart -->
    </div><!-- .grid_2 -->

    <div class="clear"></div>
</div></td><td id="catProdTd_6732686" class="productItem"><div class="product_li item-on-sale-0 adamHays hide">
    <div class="grid_3">
        <img class="sale-0" src="/images/sale.png" />
        <div class="prev">
            <a href="/store/prints/no-time-to-lose"><img id="catsproduct_6732686" src="/images/Artists/Adam Hays/1128.jpg" alt="No Time To Lose" border="0" /></a>
        </div><!-- .prev -->
    </div><!-- .grid_3 -->

    <div class="grid_4">
        <div class="entry_content">
            <a href="/store/prints/no-time-to-lose"><h3 class="title">No Time To Lose</h3></a>

            <p>Dimensions 12x16"<br />High Dynamic Range (HDR) Pigments<br />Printed on 100% Cotton Rag</p>

<span class="favorite-link">#6732686#<a class="favoritelink" href="/FavoriteProcess.aspx?OID=6732686&amp;OTYPE=27">[+] favorites</a></span> | <a class="more" href="/store/prints/no-time-to-lose">Learn More</a>

        </div><!-- .entry_content -->
    </div><!-- .grid_4 -->

    <div class="grid_2">
        <div class="cart">
            <div class="price">
                <div class="price_new">$39.95</div>
                <div class="price_old">$59.95</div>
            </div>
            <span class="btn-buy"><input class="productSubmitInput" name="AddToCart_Submit" type="submit" value="Buy Now" onclick="AddToCart(208719,6732686,'',3,'','',true);return false;" /></span>
        </div><!-- .cart -->
    </div><!-- .grid_2 -->

    <div class="clear"></div>
</div></td><td id="catProdTd_6732687" class="productItem"><div class="product_li item-on-sale-1 adamHays hide">
    <div class="grid_3">
        <img class="sale-1" src="/images/sale.png" />
        <div class="prev">
            <a href="/store/prints/reaper"><img id="catsproduct_6732687" src="/images/Artists/Adam Hays/1140.jpg" alt="Reaper" border="0" /></a>
        </div><!-- .prev -->
    </div><!-- .grid_3 -->

    <div class="grid_4">
        <div class="entry_content">
            <a href="/store/prints/reaper"><h3 class="title">Reaper</h3></a>

            <p>Dimensions 24x16"<br />High Dynamic Range (HDR) Pigments<br />Printed on 100% Cotton Rag</p>

<span class="favorite-link">#6732687#<a class="favoritelink" href="/FavoriteProcess.aspx?OID=6732687&amp;OTYPE=27">[+] favorites</a></span> | <a class="more" href="/store/prints/reaper">Learn More</a>

        </div><!-- .entry_content -->
    </div><!-- .grid_4 -->

    <div class="grid_2">
        <div class="cart">
            <div class="price">
                <div class="price_new">$39.95</div>
                <div class="price_old"><span style="text-decoration:line-through;">$69.95</span></div>
            </div>
            <span class="btn-buy"><input class="productSubmitInput" name="AddToCart_Submit" type="submit" value="Buy Now" onclick="AddToCart(208719,6732687,'',3,'','',true);return false;" /></span>
        </div><!-- .cart -->
    </div><!-- .grid_2 -->

    <div class="clear"></div>
</div></td></tr></table>
4

2 に答える 2

1

コンテナ div を追加する必要がある場合は、次のようなものを使用できます。

$('body').append('<div id="#upsell"></div>');

注:body製品を入れる必要があるコンテナdivに置き換えてください。

次に、これは .product_li の各インスタンスを繰り返し処理し、ID #upsell の div に追加します。

$('.product_li').each(function() {
    $('#upsell').append($(this).html());
});

次に、次を実行してテーブルを削除できます。

$('.productTable').remove();
于 2013-10-30T21:18:22.530 に答える