如何使用 jquery 克隆“添加到购物车”按钮

How to clone an Add to cart button with jquery

如何使用 jQuery 将 "Add to cart" 按钮复制到另一个地方?

.clone() 也许吧?

这是我要克隆的按钮

<form id="buyForm" class="hidden-print" novalidate="novalidate">
<input type="number" class="quantity" value="1" required="" min="1">
<button type="submit" data-buy-button="" data-addurl="/shoppingcart/add/5010753401" data-dependent-accessory="" data-addresponse="Dropdown" class="btn btn-success ladda-button btn-buy buy btn-lg big" data-style="zoom-out" data-add-to-cart-ticket="L3Byb2R1Y3QtcGFnZS9wcm9kdWN0LWluZm9ybWF0aW9uOyM7cHJvZHVjdF9rZXk7NTAxMDc1MzQwMTE7Izs">
<span class="ladda-label">Add to cart</span></button>
</form>    

这是我为了复制或 "clone" 按钮而创建的代码

$( "body" ).prepend( "<div class='stickyDiv'></div>" );
$(".stickyDiv").css({"z-index": "99", "position": "fixed", "bottom": "0", "height": "100px", "width":"100%","margin":"0", "background":"#0278c1", "opacity":"0.5"});
$( "#buyForm" ).clone().appendTo( ".stickyDiv" );

看到这个:

var button = $( "#buyForm button" ).clone();
$( ".stickyDiv" ).append(button);

或:

$( "body" ).prepend( "<div class='stickyDiv'>"+button[0].outerHTML+"<div>" );