i use jquery slide toggle to show/hide a div when a bttn clicked. Is it possible to place the div IN THE BUTTON ? (I need this for beeing able to stick the navigation properly on the top of the page which is for mobile devices.)
The HTML
<div class="medianavbttn">Show Menu</div>
<div class="medianav">
<ul id="medianav-links">
<li class="current"><a href="#section1">About</a></li>
<li><a href="#section2">Gallery Photos</a></li>
<li><a href="#section3">Contact</a></li>
</ul>
</div>
The Script
<script>
$(".medianavbttn").on("click", function(){
$(".medianav").slideToggle("slow");
$(this).text($(this).text() == "Show Menu" ? "Hide Menu" : "Show Menu");
});
</script>
The CSS
.medianavbttn {
position: relative;
display:block;
width: 100%;
height: 30px;
top: 0;
left: 0;
cursor: pointer;
}
.medianav {
position: relative;
display: none;
width: 100%;
}