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

161
Views
Cómo activar el botón al hacer clic en una etiqueta

Tengo una etiqueta de anclaje y un botón dentro del mismo padre div.

Al hacer clic en un ancla, también debe hacer clic en el botón a través del código.

A continuación se muestra mi HTML

 <div class="product_list"> <a class="action tocart primary new_add_to_cart"><span>Add to cart</span></a> <button type="submit" id="product-addtocart-button-927" title="Add to Cart" class="main-add-tocart action tocart primary"> <span>Add to cart</span> </button> </div> <div class="product_list"> <a class="action tocart primary new_add_to_cart"><span>Add to cart</span></a> <button type="submit" id="product-addtocart-button-928" title="Add to Cart" class="main-add-tocart action tocart primary"> <span>Add to cart</span> </button> </div>

A continuación se muestra el código JavaScript que traté de usar

 $(document).on('click','.new_add_to_cart',function(){ var pin = $.cookie('delivery-pincode'); if(!pin){ alert("hii2"); } else{ $(this).closest(".main-add-tocart").trigger("click"); } });

En la condición else, quiero que se haga clic en el botón más cercano (hermano), tengo varios productos (divs principales con la misma clase .product_list) y solo quiero hacer clic en el producto "actual".

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!