Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Eugeny Venegrad

🏠
Working from home
View GitHub Profile
@Venegrad
Venegrad / ScrollBarWidth
Last active Apr 4, 2019
Get ScrollBarWidth jquery
View ScrollBarWidth
function getScrollBarWidth(bool) {
if(bool == true) {
var $outer = $('<div>').css({visibility: 'hidden', width: 100, overflow: 'scroll'}).appendTo('body'),
widthWithScroll = $('<div>').css({width: '100%'}).appendTo($outer).outerWidth();
$outer.remove();
return 100 - widthWithScroll;
} else {
return 0;
}
}
View click_outside
$(document).click(function (event) {
if (!$(event.target).closest(".selector").length) {
// what event
}
event.stopPropagation();
});