Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

JavaScript count list items

var ul = document.getElementById("myul");
var liNodes = [];

for (var i = 0; i < ul.childNodes.length; i++) {
	if (ul.childNodes[i].nodeName == "LI") {
		liNodes.push(ul.childNodes[i]);
	}
}
Comment

JavaScript count list items


var myUL = document.getElementById("myUL");
var list = myUL.children.tags("LI");
alert(list.length);

Comment

count number in a list javascript

let arr = [1,1,1,2,2,3]

var count = new Map();
for(num in arr){
   if (count.size !== 0 && count.has(arr[num])){
          count = count.set(arr[num],1+ count.get(arr[num]))
          }
        else{
            count = count.set(arr[num],1);}
  
/* Output

Map(3) { 1 => 3, 2 => 2, 3 => 1 }
*/
     
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript split sentence into words 
Javascript :: node js sqlite3 
Javascript :: nodejs buffer.from base64 
Javascript :: javascript format date time 
Javascript :: unfocus javascript 
Javascript :: regex string case insensitive 
Javascript :: javascript canvas to image 
Javascript :: string compare on date in js 
Javascript :: urlencoded limit 
Javascript :: firebase where or 
Javascript :: clean url javascript 
Javascript :: jquery insert after next element 
Javascript :: json objects 
Javascript :: regular expression for email validation 
Javascript :: how to set input date to today date on initialization 
Javascript :: array push method 
Javascript :: substring 
Javascript :: currying in javascript 
Javascript :: angular ngmodel checkbox 
Javascript :: sapui5 get fragment by id 
Javascript :: switch case in javascript 
Javascript :: react js download file 
Javascript :: nodejs import instead of require 
Javascript :: maths 
Javascript :: react-native safeareaview 
Javascript :: jquery sibling 
Javascript :: date now js 
Javascript :: find in array function 
Javascript :: js hide div 
Javascript :: react current path 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =