I have a pair of functions I want to use to animate some navigation buttons. Basically, I want these buttons to look like buttons -- they have box-shadows enabled. And when the user clicks them, they depress -- which I figure can be shown by eliminating or reducing the box-shadows.
I'm pretty sure the functions are sound and the maps are properly formatted. But jQuery doesn't seem to be changing the box-shadow values. I tested, and it can change font color and background color and even another CSS3 attribute, border-radius:
$(document).ready(function(){
$('div#forward,div#back').mousedown(function(){
$(this).css({
'color' : 'black',
'background' : 'white',
'border-radius' : '15px',
'box-shadow' : '0px 0px 0px #444',
'-moz-box-shadow' : '0px 0px 0px #444',
'-webkit-boxshadow' : '0px 0px 0px #444',
});
});
$('div#forward,div#back').mouseup(function(){
$(this).css({
'color':'white',
'background':'#808080',
'border-radius' : '5px',
'box-shadow' : '1px 3px 6px #444',
'-moz-box-shadow' : '1px 3px 6px #444',
'-webkit-box-shadow' : '1px 3px 6px #444',
});
});
});
Is there anything wrong with my script?
If not, is there a workaround to get jQuery (or maybe just JavaScript) to manipulate box-shadows?
Just to add a bit of freshness to this question:
As from jQuery 1.8+ you can simply use (crossbrowser)
.css({ boxShadow: '1px 3px 6px #444' })
without adding the -browserVendor-specific prefixes
One of the string literals is missing a dash. Change '-webkit-boxshadow'
to '-webkit-box-shadow'
in the first .css()
call.
If you want to use you can bind like this
$('#txtApproxFare').css('border-color', 'red')
$('#txtApproxFare').css('box-shadow', '1px red')
You can also use in single line and you can append along this
$('#txtApproxFare').css({'border-color':'red','box-shadow':'0px 0px 1px red'})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With