Advertisement
Guest User

Untitled

a guest
Jun 21st, 2016
799
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.63 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. $faqArrays=  array(
  5.   array(
  6.        "question" => "this is question 1",
  7.         "answer" => "this is the answer for the first question"        
  8.     ),
  9.     array(
  10.         "question" => "this is question 2",
  11.         "answer" => "this is the answer for the 2 question"        
  12.     ),
  13.     array(
  14.         "question"=>"this is question 7",
  15.         "answer"=>"this is the answer for the 7 question"        
  16.     )
  17. );        
  18. ?>
  19.  
  20. <script type="text/javascript" src="//code.jquery.com/jquery-1.11.0.min.js"></script>
  21.  
  22. <script>
  23.  $(document).ready(function() {
  24.  
  25.     $('.faq_question').click(function() {
  26.         var index = $(this).index();
  27.         if ($(this).parent().is('.open')){
  28.             $('.faq_answer_container .faq_answer').fadeOut();
  29.             $('.faq').removeClass("open");
  30.         }else{
  31.             $('.faq_answer_container .faq_answer:eq('+index+')').fadeIn();
  32.             $('.faq').addClass("open");
  33.         }
  34.  
  35.     });
  36.  
  37. });
  38. </script>
  39. <style>
  40. /*FAQS*/
  41. .faq_question {
  42.     margin: 0px;
  43.     padding: 0px 0px 5px 0px;
  44.     display: inline-block;
  45.     cursor: pointer;
  46.     font-weight: bold;
  47. }
  48.  
  49. .faq_answer_container {
  50.     height: 0px;
  51.     padding: 0px;
  52. }
  53.  
  54. .faq_answer{
  55.     display:none;
  56. }
  57. </style>
  58.  
  59. <div class="faq_container">
  60.    <div class="faq">
  61.        <?php
  62.             foreach($faqArrays as $faqArray){
  63.                 echo "<div class='faq_question'><h1>$faqArray[question]</h1></div>";
  64.             }
  65.         ?>
  66.            <div class="faq_answer_container">
  67.              <?php
  68.        foreach($faqArrays as $faqArray){
  69.  
  70.            echo "<div class='faq_answer'><h1>$faqArray[answer]</h1></div>";
  71.  
  72.         }
  73.        ;?></div>
  74.            </div>        
  75.     </div>
  76.  </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement