2011-04-28 33 views

回答

1

入住一下:

JQUERY:

$("#Radio1").click(function(){ 
    $("#Table2").hide(); 
    $("#Table1").show(); 
}); 
$("#Radio2").click(function(){ 
    $("#Table1").hide(); 
    $("#Table2").show(); 
}); 

HTML:

<input type="radio" id="Radio1" name="rd"/> 
Click on this radio button to show Table 1 
<br /> 
<input type="radio" id="Radio2" name="rd"/> 
Click on this radio button to show Table 2 
<br /> 
<table id="Table1" border="1" cellpadding="0" cellspacing="0" style="display:none;width:200px;"> 
    <tr> 
     <td>11</td> 
     <td>11</td> 
    </tr> 
    <tr> 
     <td>11</td> 
     <td>11</td> 
    </tr> 
</table> 
<br /> 
<table id="Table2" border="1" cellpadding="0" cellspacing="0" style="display:none;width:200px;"> 
    <tr> 
     <td>22</td> 
     <td>22</td> 
    </tr> 
    <tr> 
     <td>22</td> 
     <td>22</td> 
    </tr> 
</table> 

CLICK HERE TO SEE THE DEMO

0

使用jQuery .show() API快速,方便和瀏覽器兼容的解決方案:

$("#radio1").click(function(e){$("#table1").show();}); 
$("#radio2").click(function(e){$("#table2").show();});