Home > database >  How to use the document. The getElementsByTagName () method to obtain the elements in the specified
How to use the document. The getElementsByTagName () method to obtain the elements in the specified

Time:09-23

There are two div, for example, each div has a ul li
But I want to get a second div of li, which does not affect the first div li


  • The first divli

  • The first divli






  • Second divli

  • Second divli




How to use the document. The getElementsByTagName () method to obtain the second div of li and change the second div li without affecting the content of the first div of li's content,

CodePudding user response:

To solve?
An id can be set to ul
 
  • 123 & lt;/li>



      Var ABC=document. GetElementById (" demo ");
      Var lis=ABC. GetElementsByTagName (" li ");
  • Related