我正在嘗試創建兩個按鈕,一個會擴展div,另一個會將其摺疊。我試圖修改這段代碼,但我似乎無法讓它工作。我想我只是不明白如何不切換鏈接。展開/摺疊Div
我也試圖讓頁面加載時出現DIV。我甚至不確定這是否可以用我寫代碼的方式。
任何人都可以幫助我瞭解我需要做些什麼才能使其發揮作用。
我試圖避免使用.slideUp/.slideDown它似乎與我使用的頁面上的其他插件來干擾。
$('#click-meopen').click(function() {
var height = $("#this").height();
if(height > 0) {
$('#this').css('height','0');
} else {
$("#this").css({'position':'absolute','visibility':'hidden','height':'auto'});
var newHeight = $("#this").height();
$("#this").css({'position':'static','visibility':'visible','height':'0'});
$('#this').css('height',newHeight + 'px');
}
});
$('#click-meclose').click(function() {
var height = $("#this").height();
if(height > 0) {
$('#this').css('height','0');
} else {
$("#this").css({'position':'absolute','visibility':'hidden','height':'auto'});
var newHeight = $("#this").height();
$("#this").css({'position':'static','visibility':'visible','height':'0'});
$('#this').css('height',newHeight + 'px');
}
});
因爲當你點擊它關閉,然後重新出現的密切聯繫的一些原因。有任何想法嗎? http://jsfiddle.net/XUjAH/101/ – 2012-02-15 19:31:33
也許你在js/css中沒有jsfiddle中的其他東西?因爲它適用於我,在Firefox中。 – Razz 2012-02-16 12:04:14
現在有效。我在代碼中隱藏了一個隱藏的字符。謝謝 – 2012-02-21 05:47:41