styles.css
file that's inside the styles folder and add this bit of CSS:dt { color: #268bd2; font-weight: bold; cursor: pointer; margin: 0 0 1em 0; } dt:hover { color: #2aa198; }
That definitely helps to communicate to the site visitor that the questions are clickable.
jQuery makes it easy for us. We just have to replace our call to the .toggle()
method with a call to the .slideToggle()
method.
$('dt').bind('click', function(){
$(this).next().slideToggle();
});
Now if you view the page in your browser, you can see that the questions slide smoothly into and out of view when the question is clicked. It's easy to understand what's happening when the page changes, and the animation is a nice touch.
What just happened?
We replaced our toggle()
method with the slideToggle()
method to animate the showing and hiding of the answers. This makes it easier for the site visitor to understand the change that's taking place on the page. We also added some CSS to make the questions appear to be clickable to communicate the abilities of our page to our site visitors.
3.149.233.72