I’m developing a small application in Ruby-On-Rails. I want to hide a div in an html.erb file until a link is clicked. What is the simplest way to do this?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In your html file:
In your CSS file:
In an included javascript file, or inside of
<script>tags:The
hiddenclass is hiding the div. The jQuery function is listining for a click on the link, then preventing the link from being followed (event.preventDefault()keeps it from browsing to#)`, and lastly toggling the visibility of the div.See the jQuery API for click() and toggle().