0
這麼長的故事總結,即時通訊工作與一些jQuery的標籤和即時通訊使用此代碼。我需要一些TAB代碼的幫助,Jquery
css of the tabs:
/* ---------- INNER CONTENT (ACCORDION) STYLES ----*/
.accordian {
background-color:#fff;
margin:20px auto;
color:red;
overflow:hidden;
}
#boxOut{
width:320px;
height:410px;
overflow:scroll;
background-color:#fff;
margin:154px auto auto 38px;
}
/*.accordian {
width: 400px;
margin: 50px auto;
}
*/
.accordian li {
list-style-type: none;
padding: 0 8px;
}
.dimension {
/* height: 400px;
*/}
.odd, .even {
font-weight: bold;
height: 27px;
padding-top: 3px;
padding-left: 10px;
border: 1px solid #d8d8d8;
background: #ececec;
color: #333;
border-radius: 8px;
-moz-border-radius: 8px;
-webkit-border-radius: 8px;
margin-left:6px;
margin-right:6px;
}
.logo{
width:300px;
margin:6px auto;
}
.intownLogo{
width:255px;
margin:6px auto;
}
.spaces{
margin-top:8px;
}
JS:
$(function() {
// Hide all the content except the first
//$('.accordian li:odd:gt').hide();
$('.accordian li:odd').hide();
// Add the dimension class to all the content
$('.accordian li:odd').addClass('dimension');
// Set the even links with an 'even' class
$('.accordian li:even:even').addClass('even');
// Set the odd links with a 'odd' class
$('.accordian li:even:odd').addClass('odd');
// Show the correct cursor for the links
$('.accordian li:even').css('cursor', 'pointer');
// Handle the click event
$('.accordian li:even').click(function() {
// Get the content that needs to be shown
var cur = $(this).next();
// Get the content that needs to be hidden
var old = $('.accordian li:odd:visible');
// Make sure the content that needs to be shown
// isn't already visible
if (cur.is(':visible'))
return false;
// Hide the old content
old.slideToggle(500);
// Show the new content
cur.stop().slideToggle(500);
});
});
我jQuery是noobish充其量所以雖然我已瞭解了它的時候,我不能編輯它不破壞它...上帝知道我用盡笑。
im有問題的部分是,使用這些標籤,雖然他們工作,他們與.next()函數等工作,所以當一個標籤打開,如果我點擊相同的標籤關閉,它doesn關閉時,只有在另一個選項卡被點擊時它纔會關閉。
是林與需要幫助....東西,說
「邏輯」,如果這個標籤已經被打開和點擊,關閉當前打開的選項卡。 讓說,例如,基於上述
僞碼的代碼來:
if (cur.is(':visible') && cur.is(':clicked'))
cur.slideToggle();
感謝先進的幫助。
嘿超現實主義,謝謝你看這個。也許我應該把它放在那裏,但是,我試過這個,這是發生了什麼,如果我只是把「cur.toggle(function(){cur.show()})本身,然後它會打開,但當我點擊隱藏,然後重新打開它,然後重新打開,當我完全像它那樣添加它時,它不會做任何事情,它只是停留在所有標籤頁關閉的地方 – somdow 2012-04-10 21:26:54
必須有其他代碼在這些標籤上運行如果你有'cur .toggle(function(){cur.show()})'那麼沒有理由讓tab在關閉時關閉 - 它會嘗試在每次點擊時顯示。其他一些代碼必須給它指令'.hide ()'。 – 2012-04-10 21:39:27
大家好,這就是我堅持在大聲笑,就像我說的b4,我知道100%你的意思,但如果你看上面,這就是所有的代碼到標籤,evens和賠率被附加到標籤h1 (')。我認爲關鍵是在「$('。accordian li:even')。click(function()」,但是,我試過的是將slideToggles插入該函數並且沒有任何東西。其他事件再次發生,並且沒有任何事情......並且就像我說的b4,上面的代碼是這些標籤的唯一代碼。在微網站上的所有其他內容我編碼了,所以即時確認 – somdow 2012-04-10 22:08:31