Child element clicks cannot bubble to parent element

problem description

bind the click event to the li. As a result, clicking on the li tag in li will not bubble on the parent element li. Only clicking on the rest of the li will trigger the click event

related codes

document.querySelector(".vertical").addEventListener("click", function(event) {
      console.log(event.target)
      var e = event.target;
      if (e.nodeName.toLowerCase() == "li"){
        var iconfont = e.querySelector(".iconfont");
        if (iconfont) {
          if (iconfont.innerHTML == "") {
            iconfont.innerHTML = ""
            iconfont.nextElementSibling.style.display = "block";
          }else {
            iconfont.innerHTML = ""
            iconfont.nextElementSibling.style.display = "none";
          }
        }  
      }
    }, false)
    //html
    <ul class="vertical">
    <li>
      <a href="-sharp"></a>
      <span class="iconfont"></span>
      <ul>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
      </ul>
    </li>
    <li>
      <a href="-sharp"></a>
      <span class="iconfont"></span>
      <ul>
        <li></li>
        <li></li>
        <li></li>
      </ul>
    </li>
    <li><a href="-sharp"></a></li>
    <li><a href="-sharp"></a></li>
  </ul>

actual situation

at first, click on li span without response, and then click near the edge of the box, which is fine. I don"t know why

Jul.31,2021
The

a tag already has a default event. If you write it this way, the a tag has no value (that is, a hand-changing icon), so you might as well just remove it or penetrate it with a css pointer event.


address: https://www.cnblogs.com/liuga.
I'm just a porter of nature
document.querySelector ('.mom'). AddEventListener ('click', function (event) {

)
            var e = event.target;
            while(e !== this) {
                if(e.tagName.toLowerCase() == 'li') {
                    console.log('li click~');
                    break;
                }
                e = e.parentNode;
            }

            if(e.nodeName.toLowerCase() == 'li') {

                var iconfont = e.querySelector('.iconfont');

                if(iconfont) {
                    if(iconfont.innerHTML == '') {
                        iconfont.innerHTML = ''
                        iconfont.nextElementSibling.style.display = 'block';
                    } else {
                        iconfont.innerHTML = ''
                        iconfont.nextElementSibling.style.display = 'none';
                    }
                }
            }
        }, false)
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e34cc4-59332.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e34cc4-59332.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?