【发布时间】:2018-01-10 10:03:41
【问题描述】:
除div .search-bar 一个元素外,如何使整个主体变暗。在我的情况下,它只会在点击时变暗,之后什么也不做!
但我的目标是专注于点击,如果它被点击到任何其他深色区域
<div class="search-bar">
<input type="text" class="search-btn" placeholder="Поиск по ключевым словам">
</div>
还有->
$(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,
});
});
}
【问题讨论】: