jquery - CSS dropdown not closing on click -


i hope me hint have done wrong, because dropdown won't close when user clicks on 1 of subitems. stays open until click anywhere outside.

i still quite novice when comes css , jquery, please don't hard on me ;)

here link development of site: http://prestigetrips.com/pricklybay/

when hover on "marina", that's dropdown.

here css:

 #mainnav {     position: fixed;     width: 700px;     height: 44px;     margin-top: 40px;     float: right;     right:0;     box-sizing:border-box;     text-transform:uppercase;     font-size: 0.85em;     z-index: 100; } #mainnav ul {     float:right;     width:100%;     padding:0;     margin:0;     list-style-type:none;    } #mainnav ul li {     float:right;     margin-right: 0; } #mainnav ul > li:first-child a{     float:right;     margin-right: 0; }  #mainnav ul ul {     display: none; }  #mainnav ul li:hover > ul {     display: block; }  #mainnav ul ul {     background: rgb(88,38,125);      opacity: 0.9;     -webkit-opacity: 0.9;     -moz-opacity: 0.9;     border-radius: 0px;      position: absolute;      top: 44px;     left: 0px;     width:250px; } #mainnav ul ul li {     float: left;      border-top: none;     position: relative;     border-bottom: 1px dotted #b6a0c1;     width: 100%;     color: rgb(234,222,239); } #mainnav ul ul li:last-child{     border-bottom: none; } #mainnav ul ul li {     color: rgb(223,207,231);     float:left;     text-decoration:none;     padding: 22px 12px 22px 90px; } #mainnav ul ul li:first-child a{     float:left;     margin-right: 0; } #mainnav ul ul li:hover{    margin-right: 0; } #mainnav ul ul.dropdown li:nth-child(2) hover + li {     margin-right: 0;     border-bottom: 1px dotted #b6a0c1; } #mainnav ul ul li a:hover {      -webkit-transition: .2s ease-in-out;        -moz-transition: .2s ease-in-out;       -ms-transition: .2s ease-in-out;        -o-transition: .2s ease-in-out;        transition: .2s ease-in-out;      color: #fff; } #mainnav ul ul li:hover {     background: rgba(123,73,146,0.9);     padding:0;     padding-bottom: 1px;     border: none; } #mainnav ul li.active > a, #mainnav ul li.active {     pointer-events: none;     cursor: default; } 

and javascript slideup / slidedown (i assume have add here make menu close on click?):

$(document).ready(function(){         $('#mainnav li').hover(function(){             $('ul', this).slideup(0).stop(true, true).slidedown(300);         },          function(){             $('.dropdown', this).css("display", "block").stop(true, true).delay(50).slideup(300);         });      }); 

i hope can me out, thank in advance!

because there no handler click of dropdown

$(document).ready(function () {     $('#mainnav li').hover(function () {         $('ul', this).slideup(0).stop(true, true).slidedown(300);     }, function () {         $('.dropdown', this).css("display", "block").stop(true, true).delay(50).slideup(300);     });      //hide on click     $('#mainnav ul ul li').click(function () {         $(this).closest('.dropdown').css("display", "block").stop(true, true).delay(50).slideup(300);     }) }); 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -