Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to get the nth child of dom js

 //method one 
  var c = document.getElementById("myDIV").childNodes;
  c[1].style.backgroundColor = "yellow";//first child
  c[2].style.backgroundColor = "red";//second child
  c[-1].style.backgroundColor = "green";//last child
  c[-2].style.backgroundColor = "blue";//secound last child
//method two
 let nth-child = document.querySeletorAll('myDiv:nth-child(n)');//gives nth child 
Comment

PREVIOUS NEXT
Code Example
Javascript :: type numeric value only in textbox javascript 
Javascript :: check if there is data in localstorage 
Javascript :: remove array empty values javascript 
Javascript :: set an attribute background image javascript 
Javascript :: react native text truncate 
Javascript :: React Native Expo Scrollview Scroll to bottom 
Javascript :: convert object to json javascript 
Javascript :: how to change the color using js 
Javascript :: Get full year from date object 
Javascript :: jquery each array object 
Javascript :: onclick add class javascript 
Javascript :: change background image through props 
Javascript :: get image url in react input file or preview form image 
Javascript :: insert condition in a object javascript 
Javascript :: regex for 4 digit number javascript 
Javascript :: javascript set localstorage 
Javascript :: charcodeat vs codepointat 
Javascript :: slug generator javascript 
Javascript :: html javascript redirect 
Javascript :: vue test utils emitted 
Javascript :: jquery modal close 
Javascript :: jquery get data attribute of selected option 
Javascript :: react canvas clear 
Javascript :: check if input is touched react 
Javascript :: jquery button text 
Javascript :: javascript returned function and copy to clipboard 
Javascript :: import jsx file without extension 
Javascript :: get only day from date in javascript 
Javascript :: finding in mongoose using a name 
Javascript :: get value before change and after change js 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =