How do I apply the following css code using jquery
#centeredImage
{
-webkit-filter: grayscale(20%) invert(0) blur(1px);
}
Already tried this, didn't work
$('#centeredImage').css('-webkit-filter','grayscale(20%) invert(0) blur(1px)');
Just use filter:
$('#centeredImage').css('filter','grayscale(20%) invert(0) blur(1px)');
jQuery automatically set prefixes.
You can use WebkitFilter
instead:
$("#centeredImage").css({
WebkitFilter: 'grayscale(20%) invert(0) blur(1px)'
})
Maybe create css as a class
.centered-image
{
-webkit-filter: grayscale(20%) invert(0) blur(1px);
}
Then in jQuery
$('#centeredImage').addClass('centered-image');
At least this way your keeping the separation of javascript and styling...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.