1

when I click on title ( Title Goes Here) text. I am getting null for nextElementSibling instead of a element...

Edit

you can nest any elements inside an <a> except the following :

  1. <a>
  2. <button>
  3. follow link

<a> and<button> both are invalid..

but I am getting null for a tag.. not for button tag.... I am looking for more clarity and valid source...

if I console log console.log(document.links) .. it's give three HTMLCollection collection...

End Edit

Below Example Code

  console.log(document.links)

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);
 console.log(e.target.parentElement.nextElementSibling.nextElementSibling.nextElementSibling.nextElementSibling);

    }

  })
})
<li style="border-bottom: 1px solid #d6d6d6;margin-bottom:10px;">
  <a href="javascript:void(0)">
    <span class="viewAbstractToggleTitle" style="display:inline-block;line-height:1.6 !important">
      <span  style="font-weight: 600;font-size:16px;">
        Title Goes Here
      </span>
      <span> ( 1-10 page )</span>
    </span>
    <br>
    <div class="authors">
      <span><i class="fa fa-user" aria-hidden="true"></i>
        Author
      </span>
      <span><i class="fa fa-user" aria-hidden="true"></i>
        Author
      </span>
    </div>
      <button>
       button tag
      </button>
    <a class="inlineBlock" href="" download>
      <i class="fa fa-download" aria-hidden="true"></i> Download PDF</a>
    <a class="inlineBlock viewAbstractToggle" href="javascript:void(0)"> <i class="fa fa-eye" aria-hidden="true"></i> View Article</a>
    <div class="showTabe sTab">
      <div class="tabBox">
        <div class="tab">
          <label class="label" for="tab1_">Abstract</label>
          <label class="label" for="tab2_">Graphical of Author </label>
        </div>
        <div class="box">
          <div class="content"><input id="tab1_"> Description
          </div>
          <div class="content"><input id="tab2_">
            <p>image</p>
          </div>
        </div>
      </div>
    </div>
    <br>
  </a>
</li>
نور
  • 1,425
  • 2
  • 22
  • 38
  • 2
  • I am not clear ... . _Only childs don't have siblings by definition_ ? – نور Nov 04 '20 at 16:26
  • @noor — If someone is an only child then they have no brothers or sisters. That is what being an only child means. – Quentin Nov 04 '20 at 16:46
  • I believe my html structure is invalid . from this [doc](https://www.w3.org/TR/2011/WD-html5-20110525/text-level-semantics.html#the-a-element) an `a` tag can hold block level element . _`a` tag can not hold `a` tag as a child_ ... any doc or reference ? would anyone help ? – نور Nov 05 '20 at 10:09
  • 1
  • @Louys Patrice Bessette thanks for the source.... – نور Nov 12 '20 at 15:52