Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

access multiple classes with loop

//-----------used in chat App -------
var allChat = document.querySelectorAll('div[class^=chat-people]');
console.log("Found", allChat.length, "div which class starts with “chat-people”.");

intro = document.getElementById('intro-right');

for (var i = 0; i < allChat.length; i++) {
    allChat[i].addEventListener('click', function() {
    console.clear();
    console.log("You clicked:", this.innerHTML);
       });
}
Comment

PREVIOUS NEXT
Code Example
:: array remove duplicates javascript 
::  
Javascript ::  
::  
::  
::  
::  
::  
::  
Javascript ::  
::  
:: react native select simulator 
::  
Javascript ::  
::  
::  
:: open ilnk target js 
::  
::  
::  
::  
Javascript ::  
::  
Javascript ::  
::  
::  
::  
::  
::  
::  
ADD CONTENT
Topic
Content
Source link
Name
9+5 =