Сообщение от Jolly
|
j0hnik,
Посмотрите пожалуйста.
|
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style>
</style>
</head>
<body>
<ul>
<li class="ded"><span class="google"><a href="http://google.com" class="active">Не должна работать</a></span>
<ul class="menu" style="display: none; visibility: hidden;">
<li class="ded"><span class="google"><a href="http://google.com">Google</a></span>
</li>
<li class="ded"><span class="google"><a href="http://google.com">Google</a></span>
</li>
<li class="ded"><span class="google"><a href="http://google.com">Google</a></span>
</li>
<li class="ded"><span class="google"><a href="http://google.com">Google</a></span>
</li>
</ul>
</li>
<li class="ded"><span class="google"><a href="http://google.com">Должна работать</a></span>
</li>
<li class="ded">
<span class="google"><a href="http://google.com">Не должна работать</a></span>
<ul class="menu" style="display: none; visibility: hidden;">
<li class="ded"><span class="google"><a href="http://google.com">Google</a></span>
</li>
<li class="ded"><span class="google"><a href="http://google.com">Google</a></span>
</li>
<li class="ded"><span class="google"><a href="http://google.com">Google</a></span>
</li>
<li class="ded"><span class="google"><a href="http://google.com">Google</a></span>
</li>
</ul>
</li>
<li class="ded"><span class="google"><a href="http://google.com">Не должна работать</a></span>
<ul class="menu" style="display: none; visibility: hidden;">
<li class="ded"><span class="google"><a href="http://google.com">Google</a></span>
</li>
<li class="ded"><span class="google"><a href="http://google.com">Google</a></span>
</li>
<li class="ded"><span class="google"><a href="http://google.com">Google</a></span>
</li>
<li class="ded"><span class="google"><a href="http://google.com">Google</a></span>
</li>
</ul>
</li>
<li class="ded"><span class="google"><a href="http://google.com">Должна работать</a></span>
</li>
</ul>
<script>
var el = document.querySelectorAll("ul>li");
for (var i=0; i<el.length; i++) {
if (el[i].querySelector("ul") !== null){
el[i].querySelector("span>a").onclick = function(){
event.preventDefault();
}
}
};
</script>
</body>
</html>
Надеюсь больше ничего нового не придумаете!