Thứ Tư, 25 tháng 12, 2013

Lấy giá trị của vòng lặp - Accordion



************* tìm giá trị đầu tiên vòng lặp
 $first_class = "firstbox";
 
  for($i=0;$i<sizeof($data);$i++){ 

     
    $title = $data[$i]['title'];

   <div class="hoi  $first_class">
        <div class="dap"> $title  </div>
</div>

    $first_class="";
}
************* tìm giá trị cuối cùng vòng lặp 
 $first_class = "firstbox";
 
  for($i=0;$i<sizeof($data);$i++){ 

     
    $title = $data[$i]['title'];

    if($i==sizeof($data)-1")

       <div class="hoi  $first_class">
            <div class="dap"> $title  </div>
      </div>

    $first_class="";
}
<head>
         <script type="text/javascript" >
        $(document).ready(function(){     

        $(".firstbox .dap").css({display:"block"});    
        $(".hoi").click(function(){
                if($(this).children(".dap").css("display")=="none"){
                    $(".dap").hide();
                    $(this).children(".dap").show();              
                }else{
                    $(this).children(".dap").hide();
                }          

            });              
      
        });
</script> 

</head>

links website : zaracos

Không có nhận xét nào:

Đăng nhận xét