I am trying to pass the max attribute as an integer to a jquery variable. Just can't seem to make it work. In the example the variable maxqty should be 6.
Any ideas appreciated.
HTML
<input name="qty" id="qty" type="text" value="1" size="3" maxlength="2" max="6" />
Jquery
var maxqty = 10
jQuery(function(){
jQuery("#qtyplus").click(function(){
if(jQuery('#qty').val()<maxqty)
jQuery(":text[name='qty']").val( Number(jQuery(":text[name='qty']").val()) + 1 );
});
jQuery("#qtyminus").click(function(){
if(jQuery('#qty').val()>1)
jQuery(":text[name='qty']").val( Number(jQuery(":text[name='qty']").val()) - 1 );
});
});
data-attributes.maxqtyreally is10athen numerical comparisons are going to fail. And what is that code supposed to do, because you don't seem to be trying to use themaxattribute anywhere.