0
我想只有一个打开的面板(一种手风琴菜单)。我想只有一个打开的面板(一种手风琴菜单)
我试了一下到目前为止(在代码中的注释部分):
//$('#tabs-1').show(100);
//$('#tabs-2').hide();
//$('#tabs-3').hide();
如果标签-1选择if ($('#tabs-1').is(":visible"))
然后隐藏tabs-2
和tabs-3
将被隐藏,tabs-1
将被显示,但如果我触发,之后它不会作出反应,如果我例如点击tabs-2
,因为tabs-1
仍然打开('#tabs-1').is(":visible")
(它被捕获在这个块) 它不能被关闭。我知道,这可不行我改变现有的代码,但我不认为不同的解决方案的...
可能看看如何代码看起来像:
function CloseTabInfo() {
$(".BWTabVerticalTitle").on("click", function() {
//alert("ausgeführt.");
var contentDiv = $(this).attr("data-forcolapse");
$(contentDiv).toggle(900);
if ($('#tabs-1').is(":visible")) {
//[START] Close other tabs, only one has to be opend
//$('#tabs-1').show(100);
//$('#tabs-2').hide();
//$('#tabs-3').hide();
//[END]
if ($("input:checked").val() == 1) {
$('.BWShipmentType').text('@BWHtml.translate("Documents")');
}
else if ($("input:checked").val() == 2) {
$('.BWShipmentType').text('@BWHtml.translate("Goods")');
}
//$('.BWShipmentType').text($("input:checked").val());
$('.BWTabVerticalPreferences').text($('#shippingDetails_preferences').val());
} else if ($('#tabs-2').is(':visible')) {
//[START] Close other tabs, only one has to be opend
//$('#tabs-1').hide();
//$('#tabs-3').hide();
//$('#tabs-2').show(100);
//[END]
$('.BWSenderInfo').text($('#senderAddress_SenderAddress option:selected').text());
}
else if ($('#tabs-3').is(':visible')) {
//[START] Close other tabs, only one has to be opend
//$('#tabs-1').hide();
//$('#tabs-2').hide();
//$('#tabs-3').show(100);
//[END]
$('.BWReceiverInfo').text($('#receiverAddress_matchCode').val());
if ($('#shippingDetails_payment option:selected').text() != "Choose One") {
$('.BWPaymentInfo').text($('#shippingDetails_payment option:selected').text());
}
$('.BWCostInfo').text($('#shippingDetails_CostList option:selected').text());
}
else {
//$('.BWShipmentType').text('');
//$('.BWTabVerticalPreferences').text('');
//$('.senderAddressInfo').text('');
}
});
我这对于jQuery来说是一种新鲜的东西,这让我很难解决这个简单的问题。
你应该用HTML小提琴以及使其更容易让我们来帮助你。 ** [点击这里](http://jsfiddle.net/)** –