count javascript
const collect = require('collect.js');
const collection = collect([1, 2, 3, 4]);
const x = collection.count();
console.log(`Total number of elements are : ${x}`);
// Output: Total number of elements are : 4
count javascript
const collect = require('collect.js');
const collection = collect([1, 2, 3, 4]);
const x = collection.count();
console.log(`Total number of elements are : ${x}`);
// Output: Total number of elements are : 4
counter javascript
//simple counter in javascript
// this is button element variable
const button = document.querySelectorAll(".btn")
//this variable for display counter number
const h3 = document.querySelector(".counter")
//Count variable
let count = 0;
//foreach method
button.forEach((btn) => {
//event listener function
btn.addEventListener("click", (e) => {
//event targeting element
let target = e.currentTarget
//condition for counter variable
if (target.innerText == "reset") {
count = 0;
}
else if (target.innerText == "next") {
count++;
}
else if (target.innerText == "prev") {
count--;
}
//text contains according to the if condition
h3.innerHTML = count;
})
})
js increment safety value html
function addRow(tableID) {
var table = document.getElementById(tableID);
var rowCount = document.getElementById(tableID).getElementsByTagName('tbody')
[1].getElementsByTagName('tr').length;
var row = table.insertRow(rowCount +1);
var cell1 = row.insertCell(0);
var element1 = document.createElement("input");
element1.type = "hidden";
element1.name = "Q[]";
element1.value = rowCount +1;
cell2.appendChild(element1);
cell2.innerHTML = rowCount +1;
}
function deleteRow(tableID) {
try {
var table = document.getElementById(tableID);
var rowCount = table.rows.length;
for(var i=0; i<rowCount; i++) {
var row = table.rows[i];
var chkbox = row.cells[0].childNodes[0];
if(null != chkbox && true == chkbox.checked) {
table.deleteRow(i);
rowCount--;
i--;
}
}
}catch(e) {
alert(e);
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us