This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//You can use document.getElementById('divId').className.split(/\s+/); to get you an array of class names. | |
//Then you can iterate and find the one you want. | |
var classList = document.getElementById('divId').className.split(/\s+/); | |
for (var i = 0; i < classList.length; i++) { | |
if (classList[i] === 'someClass') { | |
//do something | |
} | |
} | |
//jQuery does not really help you here... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//input[name=name] only letters and spaces | |
$('input[name=name]').on('keydown', function(e) { | |
var key = event.keyCode; | |
return ((key >= 65 && key <= 90) || key === 8 || key === 32); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function initMap() { | |
var mapCanvas = document.getElementById('map'); | |
var myLatlng = new google.maps.LatLng(43.235501, 13.633698); | |
var mapOptions = { | |
center: myLatlng, | |
zoom: 17, | |
disableDefaultUI: true, | |
styles: [ | |
{ | |
featureType: "all", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.map iframe, | |
.map ymaps { | |
pointer-events: none; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('a[href^="#"]').click(function(){ | |
var target = $(this).attr('href'); | |
$('html, body').animate({scrollTop: $(target).offset().top}, 500); | |
return false; | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).mouseup(function (e) { | |
var container = $("YOUR CONTAINER SELECTOR"); | |
if (!$(e.target).closest(container).length){ | |
container.hide(); | |
} | |
}); | |
//что означает следующее - если клик был по области, которая НЕ является нашим div'ом или не содержится в нем, то скрыть блок. | |
//Это решает проблему, если клик был по элементу вложенному в блок (не по самому блоку). Элемент будет скрыт, только если клик по области ВНЕ div'a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('.go-top').click(function() { | |
$('html, body').animate({scrollTop: 0}, 300); | |
}); | |
//go-top | |
$(window).scroll(function() { | |
if ($(window).scrollTop() > 150) { | |
$('.go-top').fadeIn(); | |
} else { | |
$('.go-top').fadeOut(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getUrlVars() { | |
var vars = {}; | |
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) { | |
vars[key] = value; | |
}); | |
return vars; | |
} | |
$(document).ready(function() { | |
//read get variable | |
var activate = getUrlVars()['activate']; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(".only_english_chars").on("keypress", function(event) { | |
var englishAlphabetAndWhiteSpace = /[A-Za-z ]/g; | |
var key = String.fromCharCode(event.which); | |
if (event.keyCode == 8 || event.keyCode == 37 || event.keyCode == 39 || englishAlphabetAndWhiteSpace.test(key)) { | |
return true; | |
} | |
return false; | |
}); | |
$('.only_enlgish_chars').on("paste",function(e) { | |
e.preventDefault(); |