Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

vanilla js for each element add attribute

const linksArray = Array.from(document.querySelectorAll('section a')); // we use Array.from to transform the NodeList from querySelectorAll to an array. Needs to IE11

linksArray.forEach(linkEl => { // we search for every span and em inside the link
 linkEl.setAttribute("list-span", linkEl.querySelector('span').textContent);
 linkEl.setAttribute("list-em", linkEl.querySelector('em').textContent);
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: node sass version 6.0.0 is incompatible with 4.0.0 
Javascript :: npm dinosaur game 
Javascript :: alpiee js hide amother button click 
Javascript :: animating in activityindicator 
Javascript :: javascript perms 
Javascript :: freecodecamp Drop it 
Javascript :: javascript concurrency 
Javascript :: javascript array filter exercises 
Javascript :: time ago function web 
Javascript :: javascript split domain 
Javascript :: jquery timeout 
Javascript :: patch if else use 
Javascript :: vue unit tests form submit 
Javascript :: Merge Arrarys of Object of Any size 
Javascript :: override submit button javascript 
Javascript :: navigation with load page in angluar 
Javascript :: find component inside tree with enzyme shallow wrapper 
Javascript :: nested ternaries react 
Javascript :: sintaxis map javascript 
Javascript :: generator object loop over length 
Javascript :: clear input field javascript 
Javascript :: redux extension link 
Javascript :: how to get second low value in js 
Javascript :: javascript use numbers as objects 
Javascript :: child to perent data transfer in angular 
Javascript :: Node-Red Custom UI 
Javascript :: how to render req.session.name to ejs 
Javascript :: Variable As Parameter In Self Invoking Function 
Javascript :: Return A "Constructor" Function 
Javascript :: js extend list 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =