Javascript Code For Li Tag Child Node Onclick
Part of : Javascript for li tag onclick location JavaScript code for li tag onclick : Onclick issue on span tag. Below JS working fine if i use single class name in span tag,but if
Solution 1:
Rather than going with class you can find the parentNode and get your desired functionality
Javascript
document.getElementById("hd_vertical").addEventListener("click",function(e) {
if(e.target.nodeName == "LI") {
var _anchor = e.target.id;
changeLocation(_anchor);
} else if(e.target.nodeName == "SPAN") {
var span = e.target;
var li = span.parentNode;
var _anchor = li.id;
changeLocation(_anchor);
}
});
Hope it helps....
Post a Comment for "Javascript Code For Li Tag Child Node Onclick"