I wanted to if I could do this with only using javascript. I have a pdf links on each of my checkboxes. So if the selected checkboxes are checked then it would go to that links but only when the button is clicked.
$(function() {
$("input[name='check[]']").bind("myCustomButtonClick", function() {
var item = $(this);
if (item.is(":checked")) {
item.siblings('a.dev-link').trigger('click');
}
});
})
$(document).on('click', '#dl-link', function() {
$("input[name='check[]']").trigger("myCustomButtonClick");
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<label id="link" class="w-checkbox dl-check-wrap">
<div class="w-checkbox-input w-checkbox-input--inputType-custom dl-check dev-check w--redirected-checked"></div>
<input type="checkbox" name="check[]" data-name="check[]" id="mode">
<a href="https://drive.google.com/uc?export=download&id=17XNOXQ3dKZM9tznx4xGk8I0O5hcvw0kc" class="dl-link dev-link">Link</a>
<span class="d-none w-form-label" for="check[]">Checkbox 4</span>
</label>
<a id="dl-link" href="#" class="dl-btn w-button">Download All</a>
Aucun commentaire:
Enregistrer un commentaire