Get Directions Button

by Ryan Brackett

HTML

<!-- start GET DIRECTIONS ITEM -->
<div class="item-get-directions">
<button class="get-directions-btn">Get Directions</button>
<form action="http://maps.google.com/maps" method="get" target="_blank">
   <input type="text" name="saddr" value="Enter your location"/>
   <input type="hidden" name="daddr" value="350 5th Ave New York, NY 10018 (Empire State Building)" />
   <input type="submit" value="Get directions" />
</form>
</div>
<!-- end GET DIRECTIONS ITEM -->

<!-- start GET DIRECTIONS ITEM -->
<div class="item-get-directions">
<button class="get-directions-btn">Get Directions</button>
<form action="http://maps.google.com/maps" method="get" target="_blank">
   <input type="text" name="saddr" value="Enter your location"/>
   <input type="hidden" name="daddr" value="350 5th Ave New York, NY 10018 (Empire State Building)" />
   <input type="submit" value="Get directions" />
</form>
</div>
<!-- end GET DIRECTIONS ITEM -->

<!-- start GET DIRECTIONS ITEM -->
<div class="item-get-directions">
<button class="get-directions-btn">Get Directions</button>
<form action="http://maps.google.com/maps" method="get" target="_blank">
   <input type="text" name="saddr" value="Enter your location"/>
   <input type="hidden" name="daddr" value="350 5th Ave New York, NY 10018 (Empire State Building)" />
   <input type="submit" value="Get directions" />
</form>
</div>
<!-- end GET DIRECTIONS ITEM -->

CSS

.item-get-directions {}
.item-get-directions button { display: block; }
.item-get-directions form {display: none;}
.item-get-directions.active button { display: none; }
.item-get-directions.active form {display: block;}

JavaScript

//start MOBILE NAV
$('.get-directions-btn').click(
    function () {
        $(".item-get-directions").removeClass("active");
        $(this).parent().toggleClass("active");
    }
);
//end MOBILE NAV