I have a <button>
that when clicked, toggles a series of div's that allows a user to delete a page.
I am trying to make it so if the user does anything else that doesn't involve deleting a page, the button reset's and the series of div's disappear.
Could anyone help me?
Here is my jsfiddle - Basically, when I click show "Show Buttons", I want the buttons to show like they do. But I click on anything else but the buttons that appear (delete-page
), I want the buttons to disappear again. Like a bootstrap dropdown toggle works.
//this is the button to activate the showing of the delete buttons
$('button.delete-pages').click(function (e) {
var btn = $(this);
//this hows the delete buttons that a user can click
$('button.delete-page').toggleClass('active');
//this just makes the button looked pushed down
btn.toggleClass('active');
});
.show { display:block; }
All the buttons are in this content in the body
<div style="width:100%;border-bottom:1px solid black;">
<button class="delete-pages">Show Buttons</button>
</div>
<ul id="projectPageList">
<li id="page_1">
<button style="float:right;" class="delete-page">
<i class="fa fa-trash-o"></i>
</button>
<a class="page" href="#page1">Page 1</a>
</li>
<li id="page_2">
<button style="float:right;" class="delete-page">
<i class="fa fa-trash-o"></i>
</button>
<a class="page" href="#page2">Page 2</a>
</li>
<li id="page_3">
<button style="float:right;" class="delete-page">
<i class="fa fa-trash-o"></i>
</button>
<a class="page" href="#page3">Page3</a>
</li>
</ul>