Responsive web-Design:
On the mobile side, usually the navigation menu is double-clicking the Jump page, and clicking the event shows only the level two list.
$ ("a"). Click (function () {
if (restriction condition) {
if ($ (this). Siblings ("ul"). Length! = 0) {
return false; There is a level two menu to disable jump
}
}
});
$ ("a"). DblClick (function () {
Window.location.href = $ (this). attr ("href"); Double-click Jump
});
Example
<! DOCTYPE html>
<meta charset= "UTF-8" >
<title></title>
<style>
. menu {
Display:none;
}
</style>
<body>
<ul class= "Main-menu";
<li>
<a href= "http://www.baidu.com" > Level menu </a
<ul class= "menu",
<li>
<a href= "http://www.weibo.com" > Level two menu </a>< br> </li>
</ul>
</li>
<li>
<a href= "http://www.baidu.com" > First level menu </a>
</li>
<li>
<a href= "http://www.baidu.com" > Level menu </a>
</l I>
<li>
<a href= http://www.baidu.com > Level menu </a>
</li>
<li>
<a href= "http://www.baidu.com" > Level menu </a>
<ul class= "menu";
<li>
< ; a href= "http://www.weibo.com" > Level two menu </a>
</li>
</ul>
</li>
</ul>
<script src= "Https://code.jquery.com/jquery-3.1.1.min.js" ></script>
<script>
$ (function () {
$ ('. Main-menu '). Children ("Li"). each (function () {
$ (this). Find ("a"). Hover (function () {
$ (this). Siblings (". Menu"). Show ();
}, function () {
$ (this). Siblings (". Menu"). Hide ();
});
})
$ ('. Main-menu '). Children ("Li"). each (function () {
/* Click Disable */
$ (this). Children ("a"). Click (function () {
if ($ (window). Width () <= 768) {
if ($ (this). Siblings (". Menu"). Length! = 0) {
return false;
}
}
});
/* Double-click Jump */
$ (this). Children ("a"). DblClick (function () {
Window.location.href = $ (this). attr ("href");
});
});
});
</script>
</body>
Click event Disable, double-click event Jump