Show on hover, hide on click with jQuery -
i've been trying basic move in jquery i'm beginner in it. how achieve that?
here code far :
jquery(document).ready(function () { // show/hide jquery('#div').hide(); //hide @ beginning jquery('#hover').hover(function () { jquery("#div").show(400); jquery('#hover').text('-'); jquery('#hover').addclass('click'); jquery('.click').height('auto'); jquery('.click').width('auto'); jquery('.click').css("font-size", "1em"); }), jquery("#div").hover(function () { //nothing on hover on }, function () { //hide on hover out }); }); my html markup following :
<a id="hover" href="javascript:;">hide</a> <div id="div">test</div> i got feeling i'm in wrong way it. can me?
your syntax seems little off, you've declared 2 hover functions , don't have click handler?
try this:
$('#hover') .mouseenter(function() { $('#div').show(); }) .click(function(e) { e.preventdefault(); $('#div').hide(); });
Comments
Post a Comment