0

I'm trying to move (prepend specifically) the content of a class into a div.

Here is the class I want to be moved:

<font class="pricecolor colors_productprice">
   <span class="PageText_L483n">
      <span itemprop='price'>$11.00</span> per 2 oz bag</span>
</font>

And here is the id I want it to be moved into:

<td valign="top">
   <span class="PageText_L71n">Quantity:</span>
   <input type="text" class="v65-productdetail-cartqty" name="QTY.KCJ-CP" size="3">
</td>

And here is the current unsuccessful jQuery attempt:

<script>
$(document).ready(function(){
    $("#v65-productdetail-action-wrapper").prepend(".PageText_L483n");
});
</script>

You can't tell from the provided code but "#v65-productdetail-action-wrapper" is the container that the second block of code is in. As you probably already know, this is simply prepending the literal string ".PageText_L483n", not its content.

4

1 回答 1

0
$("#v65-productdetail-action-wrapper").prepend($(".PageText_L483n").first());

To remove

$(".PageText_L483n").first().html("");

Or

$(".PageText_L483n").first().remove();

Both should work.

What you will have to do for the break is append a
to the class and the prepend it to the id.

$("#v65-productdetail-action-wrapper").prepend($(".PageText_L483n").first().append("<br>"));

Should do it.

于 2013-07-03T00:53:18.913 回答