开发者

how to wrap questions and answers in jQuery

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');
   });
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜