javascript - Open a class div on click -
so making website, , want when click on navigation link (hyperlink) show div.
this have:
i'd have classes.
thanks guys!
if you're happy use jquery , make life easier, can achieve result expected that:
html
<ul> <li><a class="mylink" href="#">services</a></li> </ul> <div class="alert-message notice"> here! <a class="mylink" href="#">hide</a> </div>
css
.alert-message { display:none; position: relative; border: 1px solid #ddd; background-color: #f9f9f9; -webkit-box-shadow: 0px 1px 1px 0px rgba(180, 180, 180, 0.1); -moz-box-shadow: 0px 1px 1px 0px rgba(180, 180, 180, 0.1); box-shadow: 0px 1px 1px 0px rgba(180, 180, 180, 0.1); font-weight: bold; padding: 10px 40px; margin-bottom: 20px; } .alert-message.error { background-color: #ffe9e9; border-color: #e99f9f; color: #d25c5a; } .alert-message.error { color: #d25c5a; margin: 0 auto; }
javascript
$(function () { $("a.mylink").on("click", function (e) { e.preventdefault(); $("div.alert-message").toggle(); return false; }); });
working link: http://jsfiddle.net/j9ebs/
Comments
Post a Comment