Reputation: 8020
I am trying to accomplish simple calculation on few variables. I need to take the value from the
<td class="productprice">
and multiply it by the value from the
<input type="text" class="quantityBox" value="1"/>
And, I am using this piece of code to see if the value change to recalculate.
$(".quantityBox").change(function(){
alert("Asdasd");
});
And nothing happens. I am expecting the alert box to appear for now, so I'll just be sure that the change works.
Any ideas? Thank you.
Upvotes: 0
Views: 81
Reputation: 219938
Your code works for me: http://jsfiddle.net/8RsXF/ .
If you want to do the calculation after every keypress use keyup
:
$(".quantityBox").keyup(function(){
alert("Asdasd");
});
Upvotes: 1
Reputation: 144912
Assuming that you've attached the handler once the DOM is ready, that should work.
Note that the change
event won't fire until focus has left the textbox.
Upvotes: 2
Reputation: 82913
Bind the change function in document ready event.
Something like:
$(function(){
$(".quantityBox").change(function(){
alert("Asdasd");
});
});
Note: I assume you are tabbing/moving out of the textbox to see if the change function is firing.
Upvotes: 4