javascript - How to handle adding a close link within an UL/LI item -
i've got code so:
<ul id="ulpersonal"> <li class="break etime"> <p>manage time card.</p> <div id="detime"> content </div> </li> </ul>
the div appears once hove on li
item, in jquery:
$('#detime').hide(); //initially hide div... //when user hovers show div $(".etime").hover(function () { $('#detime').fadein('slow'); });
so page shows li item, hove on , div shown. tried when "un-hover" off li div disappears, ux not friendly...to flickering.
so decided add close hyperlink...but if add within li item , click on it, div reappears still "hovering" inside li. how can handle can allow user close div?
i've got lot of seperate ul
items this, dont want add close link after ul, , cannot add href
tag outside of li, plain wrong.
try use .mouseenter() instead of .hover() because since passing 1 callback .hover()
called both mouse enter , leaving conditions
$('#detime').hide(); //initially hide div... $('#closeit').hide(); //initially hide div... //when user hovers show div $(".etime").mouseenter(function () { $('#detime').fadein('slow'); $('#closeit').show(); //initially hide div... }); $("#closeit").click( function(){ $('#detime').hide(); //initially hide div... $('#closeit').hide(); });
demo: fiddle
Comments
Post a Comment