2012-11-10 24 views
-2

如何將這個結合成1個腳本?如何結合jquery

$('#tabs, #tabs-1').tabs({ 
    select: function(event, ui){ 
    $("#picture").hide(); 
    } 
}); 

$('#tabs, #tabs-2').tabs({ 
    select: function(event, ui){ 
    $("#picture").hide(); 
    } 
}); 

$('#tabs, #tabs-3').tabs({ 
    select: function(event, ui){ 
    $("#picture").hide(); 
    } 
}); 

$('#tabs, #tabs-4').tabs({ 
    select: function(event, ui){ 
    $("#picture").show(); 
    } 
}); 
+0

你是什麼意思結合起來? –

+0

讓它變得簡單.. –

+0

4次,你在'#tabs'上調用'tabs'是什麼?不明白... – elclanrs

回答

0

試試這個:

希望它適合事業:)

代碼

$('#tabs, #tabs-1, #tabs-2, #tabs-3, #tab-4').click(function() { 
    var num = $(this).attr('class'); 

    //get the number at the end of the class of this particular div   
    var lastChar = num.substr(num.length - 1) 

    select: function(event, ui){ 
     if(lastChar == "4") 
     $("#picture").show(); 
     else 
     $("#picture").hide(); 
    } 

    });