2010-03-12 51 views
0

有沒有辦法改變這個腳本作爲盲目效果。切換窗簾效果

// Andy Langton's show/hide/mini-accordion - updated 23/11/2009 
// Latest version @ http://andylangton.co.uk/jquery-show-hide 

// this tells jquery to run the function below once the DOM is ready 
$(document).ready(function() { 

// choose text for the show/hide link - can contain HTML (e.g. an image) 
var showText=''; 
var hideText=''; 

// initialise the visibility check 
var is_visible = false; 

// append show/hide links to the element directly preceding the element with a class of "toggle" 
$('.toggle').prev().append(' <a href="#" class="toggleLink">'+showText+'</a>'); 

// hide all of the elements with a class of 'toggle' 
$('.toggle').hide(); 

// capture clicks on the toggle links 
$('a.toggleLink').click(function() { 

// switch visibility 
is_visible = !is_visible; 

// toggle the display - uncomment the next line for a basic "accordion" style 
//$('.toggle').hide();$('a.toggleLink').html(showText); 
$(this).parent().next('.toggle').toggle('slow'); 

// return false so any link destination is not followed 
return false; 

}); 
}); 

FYI- 
Where it says: 
var showText=''; 
var hideText=''; 

It was originally: 
var showText='Show'; 
var hideText='Hide'; 

我刪除了顯示/隱藏文本,因爲我正在將鏈接應用到文本的不同區域。我喜歡Blind效果,而不是這種切換效果,並且如果可能的話,需要知道如何應用它。我無法找到一個基本的盲效應腳本,它允許使用將鏈接應用於任何文本,而不是使用按鈕或靜態文本。

謝謝!希望你能幫助! Tracy

回答

1

我好像想通了,DUH!通過下面的行改變1個字:

$(this).parent().next('.toggle').toggle('slow'); 

更改爲此:

$(this).parent().next('.toggle').slideToggle('slow'); 

只是改變:
.toggle.slideToggle

我也刪除了不必要的線條完全:

var showText=''; 
var hideText=''; 

原來說:

var showText='Show'; 
var hideText='Hide'; 

因爲我想應用鏈接來激活隱藏的DIV到各種文本。

也刪除了與此相關的其他線路:

$('.toggle').prev().append(' <a href="#" class="toggleLink">'+showText+'</a>'); 

返回使之成爲一個滑動效果[直線滑軌下/上與輸入/輸出從頂部/左上角來]答:我的身影 後出,改變.toggle.slideToggle的伎倆,我再換行改爲:

$(this).parent().next('.toggle').animate({"height": "toggle"},{duration: 1000}); 

代替:

$(this).parent().next('.toggle').slideToggle('slow'); 

現在我控制了速度,這使得滑動更平滑。

對於HTML,只需將類「toggleLink」應用於帶有href =「#」的任何鏈接即可。對於隱藏的DIV,應用「切換」類。