如何与jquery结合

时间:2012-11-10 06:46:02

标签: jquery

如何将其合并为1个脚本?

$('#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();
     }
});

1 个答案:

答案 0 :(得分: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();
   }

  });