I am trying to make a poll application 开发者_StackOverflowwith java and jQuery for UI. The questions will be visible but answers will be hidden. I want that when a user clicks a question the answers will slide down. But in the implementation should i make every question and it's answers in a different 'div' element. What should be my outline?
There are several ways to solve the problem, but I'd do something like this:
<div class="question">
Question
<div class="answer" style="display: none;">
Answer!
</div>
</div>
And script-wise
$(document).ready(function() {
$('.question').click(function() {
$(this).find('.answer').slideDown('fast');
});
});
精彩评论