const step = 5;
const c = [];
for (let x = 0, y = 0; x <= a.length; x += step, y += 1) {
c.push(...a.slice(x - step, x).concat(b[y]));
}
window.open("https://qna.habr.com/q/979839", "question", "resizable,scrollbars,status")
Object.values(obj).sort((a, b) => a.start.localeCompare(b.start))
`${valutes.map(element => {
return `<div value="USD">${element}</div>`
})}`
$(function()
$(document).ready(function() { ... });
(function($) {
.......
})
(jQuery);
function hello() {
console.log("HELLO WORLD")
}
hello();
(function() {
console.log("HELLO WORLD")
})()
document.addEventListener("click", (e) => {
let currentId = "";
if (e.target.classList.value === "playing-field-item") {
currentId = e.target.id;
}
console.log(currentId);
})
document.getElementById("form").innerHTML == sum
document.getElementById("form").value == sum
solEquaStr(90005) --> "[[45003, 22501], [9003, 4499], [981, 467], [309, 37]]"
function solequa(n) {
const sqrtN = Math.sqrt(n);
const result = [];
let x, y, d;
for (let i = 1; i <= sqrtN; i++) {
d = n / i;
x = (d + i) / 2;
y = (d - i) / 4
if (Number.isInteger(x) && Number.isInteger(y)) {
result.push([x, y]);
}
}
return result;
}
const button = document.querySelector(".shuffle");
const wrapper = document.querySelector(".wrapper");
const image = document.querySelectorAll(".image")
button.addEventListener("click", () => {
const images = [...image];
const shuffled = shuffle(images);
shuffled.forEach(el => wrapper.appendChild(el));
})
function shuffle(arr) {
let newArr = arr.slice();
let i = newArr.length;
let r;
let temp;
while (i--) {
r = Math.floor(Math.random() * (i + 1));
temp = newArr[i];
newArr[i] = newArr[r];
newArr[r] = temp;
}
return newArr;
}
<div class="wrapper">
<div class="image">
el1
<img src="https://trikky.ru/wp-content/blogs.dir/1/files/2020/04/22/1564314090_3.jpg">
</div>
<div class="image">
el2
<img src="https://trikky.ru/wp-content/blogs.dir/1/files/2020/04/22/1564314090_3.jpg">
</div>
<div class="image">
el3
<img src="https://trikky.ru/wp-content/blogs.dir/1/files/2020/04/22/1564314090_3.jpg">
</div>
<div class="image">
el4
<img src="https://trikky.ru/wp-content/blogs.dir/1/files/2020/04/22/1564314090_3.jpg">
</div>
<div class="image">
el5
<img src="https://trikky.ru/wp-content/blogs.dir/1/files/2020/04/22/1564314090_3.jpg">
</div>
<div class="image">
el6
<img src="https://trikky.ru/wp-content/blogs.dir/1/files/2020/04/22/1564314090_3.jpg">
</div>
<div class="image">
el7
<img src="https://trikky.ru/wp-content/blogs.dir/1/files/2020/04/22/1564314090_3.jpg">
</div>
<div class="image">
el8
<img src="https://trikky.ru/wp-content/blogs.dir/1/files/2020/04/22/1564314090_3.jpg">
</div>
<div class="image">
el9
<img src="https://trikky.ru/wp-content/blogs.dir/1/files/2020/04/22/1564314090_3.jpg">
</div>
<div class="image">
el10
<img src="https://trikky.ru/wp-content/blogs.dir/1/files/2020/04/22/1564314090_3.jpg">
</div>
</div>
<button class="shuffle">
shuffle
</button>
if (!Element.prototype.matches) {
Element.prototype.matches =
Element.prototype.msMatchesSelector ||
Element.prototype.webkitMatchesSelector;
}
if (!Element.prototype.closest) {
Element.prototype.closest = function(s) {
var el = this;
do {
if (Element.prototype.matches.call(el, s)) return el;
el = el.parentElement || el.parentNode;
} while (el !== null && el.nodeType === 1);
return null;
};
}
(function(ELEMENT) {
ELEMENT.matches = ELEMENT.matches || ELEMENT.mozMatchesSelector || ELEMENT.msMatchesSelector || ELEMENT.oMatchesSelector || ELEMENT.webkitMatchesSelector;
ELEMENT.closest = ELEMENT.closest || function closest(selector) {
if (!this) return null;
if (this.matches(selector)) return this;
if (!this.parentElement) {return null}
else return this.parentElement.closest(selector)
};
}(Element.prototype));
const input = document.querySelector(".placeholder");
input.addEventListener("keydown", (e) => {
const condition = e.target.value.length < 5 ? "new" : "password";
input.placeholder = condition;
})
<input class="placeholder" placeholder="password">
const input = document.querySelector(".placeholder");
const output = document.querySelector(".for-error");
input.addEventListener("input", (e) => {
const condition = e.target.value.length < 5 ? "the password is too short" : "";
output.textContent = condition;
})
<input class="placeholder" placeholder="password">
<span class="for-error"></span>
const repl: Type = new REPL.REPLServer();
const repl: REPLServer = new REPL.REPLServer();
.disable-hover {
pointer-events: none;
}
let timer;
window.addEventListener('scroll', () => {
clearTimeout(timer);
if (!document.body.classList.contains('disable-hover')) {
document.body.classList.add('disable-hover')
}
timer = setTimeout(() => {
body.classList.remove('disable-hover')
}, 500);
}, false);