js event binding agent pit

js binding jump event by event agency the way, my logic here is the click event tied to the outermost layer of container top, if I had written that contains e.target class, execution jumps logic. However, this approach seems to only be clicked in the above elements, there is the innermost layer of the element above the corresponding class to jump, does not take effect in the outer layer plus the same class, always I wanted to do not understand.

 document.querySelector('.container').addEventListener('click', function (e) {
            if(e.target.classList.contains('jumpUrl')){
                console.log("点击jumpurl")
            }
        },false)
<div id="container jumpUrl">
    <div id="wrap">
        <div id="s1" class="jumpUrl">s1
            <div id="s2" class="jumpUrl">s2</div>
        </div>
        <div id="s3"></div>
    </div>
</div>

 

Guess you like

Origin www.cnblogs.com/beileixinqing/p/11506132.html