How to darken entire body except of one element which is div .search-bar
. In my case it's only darken on click and do nothing after!
But my goal is to be focused on click and if it's clicked to any other area darke
This is how output should look like ->
<div class="search-bar">
<input type="text" class="search-btn" placeholder="Поиск по ключевым словам">
</div>
And ->
$(function () {
darkenColor();
});
var darkenColor = function ($color) {
var $color = $('.search-bar');
$color.click(function () {
$(function () {
var docHeight = $(document).height();
$('body').append("<div id='overlay'></div>");
$('#overlay')
.height(docHeight)
.css({
'opacity': 0.4,
'position': 'absolute',
'top': 0,
'left': 0,
'background-color': 'black',
'width': '100%',
'z-index': 5000
});
});
$(this).css({
'background' : '#fff',
'position' : 'relative',
'z-index' : 5700,
});
});
}