Answer the question
In order to leave comments, you need to log in
How to check the value of the input when clicking on the button using jquery and put it in the "date" of the button?
There is this html code:
<form class="cart">
<div class="quantity">
<input type="number" id="5e7901376755e" class="qty" name="quantity" value="1" >
</div>
<a rel="nofollow" href="#" data-quantity="1" class="add_to_cart_button">В корзину</a>
</form>
<script>
jQuery(document).ready(function($) {
$(document).on( 'change', '.quantity .qty', function() {
$(this).parent('.quantity').next('.add_to_cart_button').attr('data-quantity', $(this).val());
});
});
</script>
$(".add_to_cart_button").on('click input', function() {
$(this).data('quantity', $(this).parent().find('input.qty').val() );
});
Answer the question
In order to leave comments, you need to log in
And I thought these designs were nothing more than a draftsman's showcase.
Are there outcasts out there who order this as a real website???
OOOOoooOo, even checkboxes with a gradient... scribe...
Recently there was a question on this template, I don’t know if it’s from you from anyone else, I’m too lazy to look for it.
Specifically, in this case - if you look at psd - the resources contain svg, and since they (svg) are not heavy, it would be logical to use svg for both backgrounds and drawings - firstly, their quality will be impeccable, and secondly, specifically such svg will be an order of magnitude lighter than Jpeg or png - if they are optimized, of course.
The last time I looked, when they showed the layout, there were png 100-200 kb each, svg - backgrounds in general 1-2 kb, no more, drawings - 10-20 each. No quality loss.
To make it work for you, do not
$(this).data('quantity', $(this).parent().find('input.qty').val() );
$(this).attr('data-quantity', $(this).parent().find('input.qty').val() );
Description: Return arbitrary data associated with the first element in the jQuery collection, as set by data() or by an HTML5 data-* attribute.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question