DEV Community

Md Abdullah al noor
Md Abdullah al noor

Posted on

traversing not working | nextelementsibling giving null js

i am working for a client project .. i need to do toggle class through dom traversal..

when click on title i am getting null for nextElementSibling

some pieces of html structure ..

   document.querySelectorAll(".viewAbstractToggleTitle").forEach(function(item){

          item.addEventListener("click",function(e){

          if(e.target.parentElement.classList.contains('viewAbstractToggleTitle')){
            console.log(e.target.parentElement.nextElementSibling.nextElementSibling)
            console.log(e.target.parentElement.nextElementSibling.nextElementSibling.nextElementSibling)
            
          }

          })
          })
  <li style="border-bottom: 1px solid #d6d6d6;margin-bottom:10px;">
  <a

Top comments (0)