I need to know when I click on an element if this element has a CSS attribute. I am thinking of something like this, but it does not work:
if ($('#element').attr("text-shadow")) {
alert ('i Have')
}
else {
alert ('i dont')
}
Any tips on this one? Thanx
if( $('#element').css('text-shadow') != null ) {
/*success*/
}
else {
/*does not have*/
}
In case you want to test 'width' style property. Behavior in Firefox is slightly differ from other browsers.
if (jQuery(value).css('width') == '0px') { // width not set
jQuery(value).css('width', '320px');
}
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