lundi 26 avril 2021

jQuery - checkbox checked on new page with link

With this code I activate checkboxes on a page:

$(".cta-order").click(function() {
    var product = $(this).data('product');
    if(!$(":checkbox[value='"+ product +"']").is(':checked')) {
        $(":checkbox[value='"+ product +"']").click();
    }
});

Checkbox on the page:

<span class="wpcf7-list-item first">
   <label>
      <input type="checkbox" name="produkte[]" value="Einzelheft" class="required"> 
      <span class="wpcf7-list-item-label">Einzelheft</span>
   </label>
</span>

Button:

<a class="cta-btn cta-order" href="#bestellen" data-product="Einzelheft">Bestellen</a>

Problem: How to do this when coming from another page? When I do this:

<a class="cta-btn cta-order" href="https://www.mypage/order#bestellen" data-product="Einzelheft">Bestellen</a>

Nothing happens.




Aucun commentaire:

Enregistrer un commentaire