Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

190
Views
How to duplicate a button and it's function to another predefined location

I am trying to duplicate my woocommerce add to cart button so it can be displayed a second time lower down my product page. However, I am using a plugin that alters the add to cart form (multiple option selections) and I need the new add to cart button to submit the options selected as well. I have the following javascript to duplicate the button i need:

( function( $ ) { 'use strict'; $(window).on( 'load', function() { var button = $( $.tcAPI().addToCartButtonSelector ).first(); button.tcClone().addClass( 'custom-add-to-cart-button' )
.on( 'click', function() {
button.trigger( 'click' );} ) .appendTo( $('.my-new-button') ); } ); }( window.jQuery ) );

But I am having issues creating a div with class= "my-new-button" to have appended and replaced with the functionality of the main button.

In the exact place I want the button to appear I have used:

<div class="my-new-button">
    <input type="button"  value="Add To Cart" />
</div> 

With no success of the JS appending the div.

If my script is even proper, how should I structure the div (or other) to display the button I want? I am by no means well versed so I appreciate any advice. Thank you

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!