Skip to content

Instantly share code, notes, and snippets.

View Venegrad's full-sized avatar
🏠
Working from home

Eugeny Venegrad

🏠
Working from home
View GitHub Profile
@Venegrad
Venegrad / ScrollBarWidth
Last active April 4, 2019 15:23
Get ScrollBarWidth jquery
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;
}
}
$(document).click(function (event) {
if (!$(event.target).closest(".selector").length) {
// what event
}
event.stopPropagation();
});