Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

can i select multiple classes and give function to them at once but different in js

//-----------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
Javascript :: javascript coding challenges with solutions 
Javascript :: async/await 
Javascript :: return jsx in for loop 
Javascript :: localstorage nextjs 
Javascript :: javascaript 
Javascript :: javascript desktop app 
Javascript :: all react navigation packages 
Javascript :: Is there an “exists” function for jQuery 
Javascript :: how calculate number of digits of number 
Javascript :: line break in javascript in notification 
Javascript :: loop map with key value pair js 
Javascript :: cannon js parent child 
Javascript :: regex more than one character 
Javascript :: how to hide api key in react app 
Javascript :: curved lines on google maps usint react 
Javascript :: node mongodb $or 
Javascript :: noscript tag code string in react 
Javascript :: angular remove element from array 
Javascript :: how to add multiple style attributes in react element 
Javascript :: Swap a select text with javascript 
Javascript :: command reboot android app react native adb command 
Javascript :: geojson featurecollection 
Javascript :: check if localstorage is undefined 
Javascript :: how to categorize a data in an array of object in javascript 
Javascript :: get list of filenames in folder 
Javascript :: react hook form with controlled input 
Javascript :: json schema eg 
Javascript :: twhat is a js promise 
Javascript :: react axios POST using async await method with super constructor parent class 
Javascript :: make a if in jsx 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =