我手风琴 jsfiddle jsfiddle
jsfiddle
它左右两个柱子,每当我试图折叠右手风琴时,如果它仍然打开并试图点击左手风琴,那么右手风琴应该关闭,它怎么可能?
试试js
http://jsfiddle.net/BhBHf/3/
$(document).ready(function(){ $('.accordion .accordion-toggle').each(function(){ $(this).html('<span class="plus">+</span>'+$(this).text()); }); $('.accordion a').on('click',function(){ if($(this).children('.plus').text()==='+'){ $(this).children('.plus').text('-'); $(this).css({'color':'red'}); } else{ $(this).children('.plus').text('+'); $(this).css({'color':'#666'}); } $('.accordion').on('hide', function () { $('[href="#'+$(this).attr('id')+'"]').addClass('accordion'); }); }); });
试试这个:
http://jsfiddle.net/BhBHf/4/
$(document).ready(function () { $('.accordion .accordion-toggle').each(function () { $(this).html('<span class="plus">+</span>' + $(this).text()); }); $('.accordion a').on('click', function () { if ($(this).children('.plus').text() === '+') { $(this).children('.plus').text('-'); $(this).css({ 'color': 'red' }); $('.accordion a').not(this).children('.plus').text('+'); $('.accordion a').not(this).css({ 'color': '#666' }); $('.in').collapse("hide").removeClass("in"); } else { $(this).children('.plus').text('+'); $(this).css({ 'color': '#666' }); } }); });
我还用HTML代码重命名了你的两个手风琴 .
2 回答
试试js
http://jsfiddle.net/BhBHf/3/
试试这个:
http://jsfiddle.net/BhBHf/4/
我还用HTML代码重命名了你的两个手风琴 .