Last active
October 25, 2016 19:59
-
-
Save sbrin/5dcc616fbfbd5f980ae1dfceb40203c7 to your computer and use it in GitHub Desktop.
jQuery simple popover hides on click anywhere beside itself
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function () { | |
var pop = {}; | |
pop.shown = false; | |
pop.item = $('.popover'); | |
$('body').on('click', function(e){ | |
if ( e.target.className == 'button-block' ){ | |
if ( pop.shown == true ){ | |
pop.item.hide(); | |
pop.shown = false; | |
} else if ( pop.shown == false ) { | |
pop.item.show(); | |
pop.shown = true; | |
} | |
} else if ( e.target.className != 'popover-content' ){ | |
if ( pop.shown == true ){ | |
pop.item.hide(); | |
pop.shown = false; | |
} | |
} | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment