javascript - nextSibling NextElementSibling not reaching class -


i trying element through next sibling couldnt reach :(

<div id="main"> <ul > <li class="playerr">zero</li>     <li>one</li>     <li>two<div></div></li>   </ul> <ul>       <li>four</li>     <li>five<div></div></li>       <li class='playerr'>six</li>     </ul> </div> 

the li class of playerr(2.one) element want if click example one or zero doesnt work, works if click li within same

function kappa(o){        if (o.nextelementsibling) {       o = o.nextelementsibling;     } else {       o = o.nextsibling; // move original node..       while (o && o.nextsibling && o.nextsibling.nodetype !== 1) {         o = o.nextsibling;       }     }     if (o.nodename.tolowercase() !== 'li') {       return o;     } else {       return o;     } } // capture propagated clicks document.getelementbyid("main").addeventlistener("click", function(e) {     var next = kappa(e.target);      while(next.classname !== "playerr"){         next = kappa(next);     }      alert(next.classname);   }); 

http://jsfiddle.net/3kb3w/


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -