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
| if (document.documentElement.clientWidth > 1200) { | |
| //code | |
| } |
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 compareCode(obj1, obj2) { | |
| return obj1.code - obj2.code; | |
| } | |
| arr.sort(compareCode); | |
| // Сортировка по алфавиту | |
| arr.sort(function(a, b) { | |
| if (a.code > b.code) { |
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
| Чтобы удалить конкретный объект из массива | |
| var arr = [ | |
| {id: 1}, | |
| {id: 2}, | |
| {id: 3}, | |
| {id: 4}, | |
| ]; | |
| var indexToRemove = arr.findIndex(obj => obj.id == 2); | |
| arr.splice(indexToRemove , 1); | |
| console.log(arr); |
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
| package main | |
| import ( | |
| "fmt" | |
| "math/rand" | |
| "time" | |
| ) | |
| func random(min, max int) int { | |
| rand.Seed(time.Now().Unix()) |
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($){ | |
| $.fn.duplicate = function(settings){ | |
| var defaults = { | |
| d: ' ', | |
| cnt: 2 | |
| }; | |
| var options = $.extend(defaults, settings); | |
| this.each(function(){ |
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() { | |
| // находим select и записываем в переменную | |
| var select = document.getElementById("select__id"); | |
| if (!!!select) { | |
| return; | |
| } | |
| // отслеживаем изменение select | |
| select.addEventListener('change', function() { | |
| CalcProfit(); | |
| }); |
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
| window.addEventListener('DOMContentLoaded', function() { | |
| }); |
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
| var i = new Image(); | |
| i.onload = function(){alert(i.width);} | |
| //1. назначем обработчик события до того, как начнется загрузка рисунка. | |
| //таким образом событие сработает, при загрузке рисунка | |
| //2. выполение alert-а обрачиваем в анонимную функцию, которая выставляется в качестве обработчика события | |
| i.src = 'image.jpg'; // существующее изображение | |
| // Готовый скрипт с загрузкой картинки и удалением фона на элементе куда вставляется картинка | |
| (function() { |
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
| $(".video__link").colorbox({ iframe: true, width: 640, height: 400, maxWidth: "90%", maxHeight: "70%" }); |
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
| // Возвращает случайное целое число между min (включительно) и max (не включая max) | |
| // Использование метода Math.round() даст вам неравномерное распределение! | |
| function getRandomInt(min, max) { | |
| return Math.floor(Math.random() * (max - min)) + min; | |
| } |
NewerOlder