JSFiddle - React, Tailwind, and code Playground
HTML
<div id="box">A</div>
<div class="button">Button1</div>
<div class="button2">Button2</div>
JavaScript
$(document).ready(function () {
//attach click event to button
$('.button').click(function () {
//when button is clicked we call blurElement function
blurElement("#box", 2);
});
//attach click event to button
$('.button2').click(function () {
//when button is clicked we disable the blur
blurElement("#box", 0);
});
});
//set the css3 blur to an element
function blurElement(element, size) {
var filterVal = 'blur(' + size + 'px)';
$(element).css({
'filter':filterVal,
'webkitFilter':filterVal,
'mozFilter':filterVal,
'oFilter':filterVal,
'msFilter':filterVal,
'transition':'all 0.5s ease-out',
'-webkit-transition':'all 0.5s ease-out',
'-moz-transition':'all 0.5s ease-out',
'-o-transition':'all 0.5s ease-out'
});
}