簡體   English   中英

jQuery UI #Accordion加載然后fadeIN ......怎么樣?

[英]jQuery UI #Accordion load then fadeIN… How?

我正在使用一個基本的jQuery手風琴腳本(使用jquery ui),並且我希望該區域首先加載然后淡入該區域(因此沒有閃爍的圖像,因為它們都加載而沒有jquery然后手風琴折疊起來)。 在加載該腳本(以及#accordion和圖像)之后,我需要向下面的JS添加什么函數才能使用fadeIn?

謝謝,JG

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script>

 <script type="text/javascript">
 jQuery(document).ready(function($) {

     $("#accordion").accordion( {active: 2} );

 });
 </script>

 <style>
  #accordion {
    margin: 0px 0 0;
    width: 640px;
    min-height: 650px;
    float: left;
  }

  #accordion H2 {
    background: #f8f7f5;
    color: #582802;
    border: 1px solid #cccccc;
    cursor: pointer;
    font: 12px Arial, Helvetica, sans-serif;
    line-height: 16px;
    margin: 0 0 4px 0;
    padding: 9px 9px 9px 9px;
    font-weight: bold;
  }
 </style>

 <div id="accordion">
     <h2>Click for Image 1</h2>
     <div class="content">
         <img src="img1.jpg">
     </div>

     <h2>Click for Image 2</h2>
     <div class="content">
         <img src="img2.jpg">
     </div>

     <h2>Click for Image 3</h2>
     <div class="content">
         <img src="img3.jpg">
     </div>
 </div>

嘗試隱藏手風琴(顯示:無),然后在准備好文件時淡入。

http://jsfiddle.net/nQ6Uv/3

<div id="accordion" style="display:none;">...... </div>

$(document).ready(function(){
    $("#accordion").fadeIn("slow");
    $("#accordion").accordion( {active: 2} );  
}); 

嘿看看我的JsFiddle。

http://jsfiddle.net/thewingser/qM5cD/8/

我相信這就是你想要的。 此外,我用段落替換你的圖像只是因為jsfiddle無法解析你的圖片。

根據Lokase的要求

<html>
    <head>
<link type="text/css" rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css">
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
        <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script>
window.onload = (function(){
try{
$(document).ready(function() {
$("#accordion").accordion();
});
}catch(e){}});
</script>
        <style>
            #accordion {
    margin: 0px 0 0;
    width: 640px;
    min-height: 650px;
    float: left;
  }

  #accordion H2 {
    background: #f8f7f5;
    color: #582802;
    border: 1px solid #cccccc;
    cursor: pointer;
    font: 12px Arial, Helvetica, sans-serif;
    line-height: 16px;
    margin: 0 0 4px 0;
    padding: 9px 9px 9px 9px;
    font-weight: bold;
  }
        </style>
    </head>
<body>
<script>
    jQuery(document).ready(function(){
    $('.accordion .head').click(function() {
        $(this).next().toggle('slow');
        return false;
    }).next().hide();
});
    </script>
<div id="accordion">
     <h2>Click for Image 1</h2>
     <div class="content">
         <p>test</p>
     </div>

     <h2>Click for Image 2</h2>
     <div class="content">
         <p>test</p>
     </div>

     <h2>Click for Image 3</h2>
     <div class="content">
         <p>test</p>
     </div>
 </div>


</body>
</html>

嘗試這個:

使用Javascript

jQuery(document).ready(function ($) {

     $("#accordion").accordion({ active: 1 })
 });

 function li() {
     $(".content").fadeIn(500);
     $("#accordion").accordion({ active: this })
 }

HTML

<div id="accordion">
 <a onclick="li();"><h2>Click for Image 1</h2></a> 
<div class="content"> 
     <img src="Image/cat.jpg" width="100px" height="100px">
 </div>

<a onclick="li();"> <h2>Click for Image 2</h2></a>
 <div class="content">
     <img src="Image/catUblueUeyes.jpg"  width="140px" height="140px">
 </div>

<a onclick="li();"> <h2>Click for Image 3</h2></a>
 <div class="content"  >
     <img src="Image/jquery.jpg"  width="140px" height="140px">
 </div>




固定或分配給圖像的百分比,以避免損壞手風琴

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM