我有一個包含以下代碼的多個實例的頁面:jQuery的遍歷問題
<div class="company">
<a class="toggle" id="<%= "tgl#{company.id}" -%>">...</a>
<p>...other stuff...</p>
<div class="clear"></div>
<div class="expand_me companyExpand" id="">...
這段代碼顯示每個「板」的開始。當用戶點擊.toggle
時,我需要.expand_me
使用Jquery切換打開。
這是我的代碼到目前爲止 - 它不工作,我認爲這是由於遍歷問題。
$(".toggle").click(function() {
$(this).parent().children(".expand_me").toggle("blind", {}, 500, callback);
});
我該如何解決這個問題?
您例如不顯示在'了'標籤關閉......是'p'並列入了''或同級別的div? – 2011-05-28 10:13:52
我可能不是遍歷問題,但你如何調用'toggle'。看看它所需的參數:http://api.jquery.com/toggle/也不是沒有'href'屬性的鏈接不會被渲染爲鏈接。這工作:http://jsfiddle.net/csgHQ/ – 2011-05-28 10:16:59
@Felix,OP是使用jQuery的UI擴展版本http://jqueryui.com/demos/toggle/ – 2011-05-28 10:18:04