Onclick Button, Show & Hide A Div

Share Now

Share on facebook
Share on pinterest
Share on twitter
Share on linkedin
Share on email

# HTML CODE

<button id="filter-btn">FILTER BUTTON</button>
<div id="newpost">
   <ul>
     <li><a href="">ITEM 1</a></li>
     <li><a href="">ITEM 2</a></li>
     <li><a href="">ITEM 3</a></li>
   </ul>
</div>

# JAVASCRIPT CODE

(function($) {
    "use strict";
// A $( document ).ready() block.
$( document ).ready(function() {

	$("#filter-btn").click(function() {
	    //$("#newpost").toggle();
            $("#newpost").slideToggle();
	});

});
})(jQuery);

# JSFIDDLE LINK

Nahid Mahamud

Nahid Mahamud

Web Developer | Graphic Designer | WordPress & Woo-commerce Expert