Reputation: 2349
if ($('#quantity').val >= 1) {
$( "<p>Option #1</p>" ).appendTo( "#options" );
$('#optionone').show();
}
if ($('#quantity').val >= 2) {
$( "<p>Option #2</p>" ).appendTo( "#options" );
$('#optiontwo').show();
}
quantity is the id of a text field that gets submitted in my code. the above code should have worked (or so I thought) to display different texts for different values in the field but for some reason it just doesn't do anything.
Although this does work perfectly:
$( "<p>Option #1</p>" ).appendTo( "#options" );
$('#optionone').show();
$( "<p>Option #2</p>" ).appendTo( "#options" );
$('#optiontwo').show();
So obviously my condition code is wrong, but how else can I access the field value and do stuff according to the value of it?
Please help me out on this.
Thanks
Upvotes: 0
Views: 41
Reputation: 7735
You should be using
$('#quantity').val()
instead of
$('#quantity').val
See jQuery documentation.
Upvotes: 2