Change the amount of textbox, change image on hover with jQuery / Javascript
I would like to do 2 things in jQuery or Javascript,
-
Change the quantity in the text box with the up and down arrows. The default is 1 and I want to increase it by 1 when the user clicks the up arrow and vice versa.
-
Is it possible to change the arrow to a different image (color) when the mouse is hovering over it?
Thanks.
+1
a source to share
2 answers
I would recommend using the click()
command to change the value in the textbox and the hover()
command to change the arrow to a different image (color)
for example to increment
$('#myImg')
.click( function() {
var num = $('#myTextbox').text();
if (!isNaN(num))
$('#myTextbox').text(parseInt(num,10) + 1);
.hover(
function() { $(this).css('background-image','over.jpg'), //over
function() { $(this).css('background-image','out.jpg') // out
)
+1
a source to share