Very often you want to supply user with some information, but you don’t want to be too pushy. Present user with a link, and let him click on it so it will lead him to extended text. To do that, all you have to do is write a little bit of HTML and jQuery. To achieve this effect, you can use following snippet:
1
2
3
4
5
6
7
8
9
10
11
| <p>Click on the link to see how to use <a href="javascript:void(0);" id="how-to">toggle in jQuery</a>?</p>
<div style="display: none;" id="toggle-div">
You should not write inline style, but I used it to make example of using slide toggle with jQuery shorter.
</div>
<script>
jQuery("#how-to").click(function () {
jQuery("#toggle-div").slideToggle("slow");
});
</script> |
Example: Slide toggle div using jQuery
Click on the link to see how to use toggle in jQuery?
You should not write inline style, but I used it to make example shorter.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris auctor lacus ac metus suscipit suscipit. Nulla id dictum nisi. Sed fringilla, felis nec fringilla eleifend, erat odio convallis quam, eu tristique tellus ante vitae mauris. Sed cursus tellus et eros fermentum facilisis. Aliquam id metus viverra lacus vulputate pharetra. Donec et lectus sit amet elit pharetra lobortis. Sed in leo ligula. Nunc nisi lorem, imperdiet eu egestas nec, commodo ac libero. Nulla tincidunt interdum libero quis posuere. Quisque tristique dapibus elit, eget fringilla nulla lacinia ut. Pellentesque pellentesque, leo quis porttitor volutpat, quam sapien tempus ipsum, vitae volutpat massa elit et dui. Vestibulum id purus metus. Nulla aliquam suscipit neque at iaculis. Nulla facilisi. Pellentesque rhoncus semper sodales. Donec in quam sed turpis molestie scelerisque quis sit amet felis. Integer aliquam lorem ac felis hendrerit viverra egestas justo tempor. Fusce at augue ut dolor dictum scelerisque.