我想強調所選手風琴選項卡的背景下,它的工作,但選擇的手風琴標籤的CSS不會改變選擇其它選項卡問題與自定義手風琴
的代碼和CSS是如下
<script type="text/javascript">
$(document).ready(function ($) {
$('#accordion').find('.accordion-toggle').click(function() {
//Expand or collapse this panel
$(this).next().slideToggle('slow');
$(this).css({ "background-color": "#191970" });
//Hide the other panels
$(".accordion-content").not($(this).next()).slideUp('slow');
$(".accordion-content").not($(this)).css({ "background-color": "#E4E4E4" });
});
});
</script>
<style type="text/css">
#accordion{width:20%; float:left; height:100%; overflow:hidden; }
.accordion-toggle {cursor: pointer; background:#E4E4E4; line-height:35px; font-size:1em; padding-left:0.3em; color:#0f5595; }
.accordion-toggle img{ padding-right:0.4em; padding-top:0.3em;}
.accordion-content {display: none; float:none; }
.accordion-content.default {display: list-item; }
.accordion-content.contact{ display: list-item;}
</style>
根據我的問題是下面的語句:
$(".accordion-content").not($(this)).css({ "background-color": "#E4E4E4" });
他HTML是作爲
<div id="accordion">
<h4 class="accordion-toggle"> <img src="images/link.gif" /> first element</h4>
<div class="accordion-content default">
<ul>
<li><a href="index.html"> Security</a></li>
<li><a href="index.html"> Security</a></li>
</ul>
</div>
<h4 class="accordion-toggle"> <img src="images/link.gif" /> second element</h4>
<div class="accordion-content">
<p>Lorem ipsum dolor sit amet mauris eu turpis.</p>
</div>
</div>
我是新來的Jquery,首先,我盡我所能來解決它自己 – user3237190
什麼問題?是否有任何錯誤產生?什麼不工作? [您是否調試過Javascript](http://stackoverflow.com/questions/988363/how-can-i-debug-my-javascript-code)? – Liam
首先點擊的手風琴的元素他們也保留選定的元素的顏色 – user3237190