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
Javascript :: express-session deprecated undefined resave option; provide resave option index.js:17:9 
Javascript :: async function javascript dec 
Javascript :: crud in node 
Javascript :: cy visit cypress 
Javascript :: javascript Strict Mode in Variable 
Javascript :: javascript arrays 
Javascript :: 2d array in javascript 
Javascript :: javascript link to google maps route 
Javascript :: how to check if expo app is running on the web 
Javascript :: webpack dev srcipt 
Javascript :: react-native-charts-wrapper:compileDebugJavaWithJavac FAILED 
Javascript :: bcrypt create encrypted password 
Javascript :: repeat network call n times in js 
Javascript :: .includes javascript 
Javascript :: check when input number value goes up or down 
Javascript :: nextjs override page route 
Javascript :: $("#id").submit in vanilla 
Javascript :: reactjs npm take photo 
Javascript :: install video-react 
Javascript :: react native stack transition from right to left 
Javascript :: react native notify user for new version of app 
Javascript :: remove all white spaces and different characters globally 
Javascript :: e.target.id not working react js 
Javascript :: how sum all array element with while loop 
Javascript :: programmatically create a custom cron job drupal 7 
Javascript :: React: readmore and read less 
Javascript :: json schema e.g. 
Javascript :: split text javascript 
Javascript :: Resize Image Using HTML Canvas in JavaScript 
Javascript :: npm jwt decode 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =