const start = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), 0, 0, 0, 1);
setInterval(() => {
const arr = String((parseInt((new Date - start) / 1000))).split("");
const length = arr.length;
let html = `<div id="txt">`;
for (let i = 0; i < length; i += 1) {
html += `<span class="digit-${i}">${arr[i]}</span>`;
}
html += "</div>";
document.body.innerHTML = html;
}, 1000);
<input type="text" class="test">
<div class="result"></div>
const input = document.querySelector(".test");
const result = document.querySelector(".result");
input.onkeyup = input.oncopy = input.onpaste = input.oncut = event => {
if (event.target.value == "value") { // any some condition
result.innerHTML = event.target.value;
// or some code
}
};
const str = "Error.0.Value : This is error for item 0.\r\nError.1.Value : This is error for item 1 and this item is exist.";
let result = {};
str.split("\r\n").forEach(item => Object.assign(result, { [`someinput[${item.split(" : ")[0].match(/\d+/)}]`]: item.split(" : ")[1] }));
/*
{
"someinput[0]": "This is error for item 0.",
"someinput[1]": "This is error for item 1 and this item is exist."
}
*/
"2017-09-08T21:03:49.736Z".match(/\d+-\d+-\d+/).join();
"2017-09-08T21:03:49.736Z".match(/.{10}/).join();
"2017-09-08T21:03:49.736Z".slice(0, 10);
"2017-09-08T21:03:49.736Z".split("T")[0];
"2017-09-08T21:03:49.736Z".substring(0, 10);
[..."2017-09-08T21:03:49.736Z"].splice(0, 10).join("");
"2017-09-08T21:03:49.736Z".match(/[\d-]+/)[0]; // @romasovest
document.querySelector(".product__shopcard-btn").closest(".product"); // <div class="product"></div>
let element = document.querySelector(".product__shopcard-btn");
while (!element.classList.contains("product")) {
element = element.parentElement;
if (!element) {
break;
}
}
const find = (node, className) => {
while (node) {
if (node.classList.contains(className)) {
return node;
} else {
node = node.parentElement;
}
}
return null;
}