Skip to content

Instantly share code, notes, and snippets.

jQuery(function($){
$(document).mouseup(function (e){ // событие клика по веб-документу (or .on(touchstart click))
var div = $("#popup"); // тут указываем ID элемента
if (!div.is(e.target) // если клик был не по нашему блоку
&& div.has(e.target).length === 0) { // и не по его дочерним элементам
div.hide(); // скрываем его
}
});
});
@karamanskiy
karamanskiy / Клик вне элемента
Created July 15, 2019 09:32
Клик вне элемента
$(document).mouseup(function (e) {
let el = $(".leftmenu");
if (el.has(e.target).length === 0){
el.removeClass('active');
}
});
@karamanskiy
karamanskiy / Анимация счетчика цифр при скролле.txt
Created May 17, 2019 10:27
Анимация счетчика цифр при скролле
/* ANIMATE NUMBERS */
var isResizeble = false;
function animateNumb() {
isResizeble = true;
$('.benefits-count').each(function() {
$(this).prop('counter',0).animate({
counter:$(this).data('count')
},{
duration: 2000,
@karamanskiy
karamanskiy / Handler load and resize (Хендлер)
Last active October 22, 2021 07:23
Хендлер при загрузке и ресайзе странички
var handler = function() {
}; // end handler
$(window).bind('load', handler);
$(window).bind('resize', handler);
@karamanskiy
karamanskiy / Скролл к элементу (scroll to element)
Last active October 22, 2021 07:23
Скролл к элементу
// Скролл к элементу
$(".menu").on("click","a.scroll", function (e) {
e.preventDefault();
var id = $(this).attr('href'),
top = $(id).offset().top;
$('body,html').animate({scrollTop: top}, 600);
});
@karamanskiy
karamanskiy / Скрытие placeholder-a
Created September 23, 2018 12:14
Скрывать и показывать placeholder
// скрытие placeholder
$('input, textarea').on('focus', function () {
var $this = $(this);
var placehold = $this.attr('placeholder');
$this.attr('data-placeholder', placehold);
$this.attr('placeholder', '');
// $this.data($this, 'placeholder', placehold);
});
$('input, textarea').on('blur', function () {
var $this = $(this);
@karamanskiy
karamanskiy / Стилизация radiobutton
Created July 25, 2018 20:02
Стилизированный radiobutton
<!-- HTML -->
<label>
<input class="radio" type="radio" name="radio-test">
<span class="radio-custom"></span>
<span class="label">Lorem ipsum dolor sit amet, consectetur</span>
</label>
<!-- CSS -->
.radio {
display: none;
@karamanskiy
karamanskiy / Стилизация checkbox
Last active October 22, 2021 07:23
Стилизированный checkbox
// HTML
<label>
<input class="checkbox" type="checkbox" name="checkbox-test">
<span class="checkbox-custom"></span>
<span class="label">Lorem ipsum dolor</span>
</label>
// CSS
.checkbox {
JS:
$(".accordeon dd").hide().prev().click(function() {
$(this).parents(".accordeon").find("dd").not(this).slideUp().prev().removeClass("active");
$(this).next().not(":visible").slideDown().prev().addClass("active");
});
CSS:
.accordeon .active { color: red }
HTML:
@karamanskiy
karamanskiy / jQuery Tabs Short
Last active May 23, 2021 06:26 — forked from agragregra/jQuery Tabs Short
Простые табы
HTML:
<div class="tabs-wrapper">
<div class="tab_header">
<span class="tab">Вкладка 1</span>
<span class="tab">Вкладка 2</span>
<span class="tab">Вкладка 3</span>
</div>
<div class="tab_content">
<div class="tab_item">Содержимое 1</div>
<div class="tab_item">Содержимое 2</div>