Friday 15 July 2011

jquery - show on click but click anywhere else to hide -



jquery - show on click but click anywhere else to hide -

i creating tooltip. want user click on link display tooltip, , click anywhere else hide it. or if click on tooltip on page, current 1 should hide , new 1 show.

here current code..

$(".byr").click(function () { $(".popup").hide(); $(this).find(".popup").show(); });

the problem current code if open tooltip, there no way close it, unless open new one, can't close that...

i want user click anywhere on page close. thanks

sorry guys forgot set link code http://codepen.io/anon/pen/wtkml

try : bind click event document instead of link , check if clicked element link or not.

$(document).click(function (e) { //close popup $(".popup").hide(); //check if clicked element has class byr if(e.target.classname.indexof('byr')!=-1) $(this).find(".popup").show(); });

jquery

No comments:

Post a Comment