I am working on a slide out tab that will open and close when the user clicks on the "Feedback" button. Current logic hides the tab by default and then check the margin-right. It all works great. My only concern is how do I close the tab if I click outside it?
(function($) {
//<![CDATA[
$(document).ready(function() {
$(function() {
$('#nav').stop().animate({
'margin-right': '-230px'
}, 1);
function toggleDivs() {
var $inner = $("#nav");
if ($inner.css("margin-right") == "-230px") {
$inner.animate({
'margin-right': '0'
});
$(".nav-btn").html('<img src="http://bookbecho.com/img/feedback.png" alt="open" />')
} else {
$inner.animate({
'margin-right': "-230px"
});
$(".nav-btn").html('<img src="http://bookbecho.com/img/feedback.png" alt="close" />')
}
}
$(".nav-btn").bind("click", function() {
toggleDivs();
});
});
}); //]]>
})(jQuery);