Show/hide tables with jQuery

前端 未结 6 1517
不思量自难忘°
不思量自难忘° 2020-12-31 14:32

I have a series of tables similar to the following html code:

6条回答
  •  借酒劲吻你
    2020-12-31 15:06

    Here is a working version: http://jsfiddle.net/6Ccj7/

    Your html is broken. Change this:

To this:

Also, you used id for film when in fact you have 2 instances. You class instead:

//HEAD CONTENT 1// //BODY CONTENT 2// //BODY CONTENT 2//
//HEAD CONTENT 1//
//BODY CONTENT 1//
//HEAD CONTENT 2//
//BODY CONTENT 2//

Here is the updated JS:

$(document).ready(function(){
$('.film td').hide();});

$(document).ready(function(){
var n1 = 0;
      $('.film th.1').click(function(){
         if(n1 == 0){
         $('.film td.1').show();
         n1 = 1;
         }else{
        $('.film td.1').hide();
         n1 = 0;}
       });
var n2 = 0;
      $('.film th.2').click(function(){
         if(n2 == 0){
         $('.film td.2').show();
         n2 = 1;
         }else{
        $('.film td.2').hide();
         n2 = 0;}
       });
}); 

提交回复
热议问题