使用jquery当radio,id="yes"选中时,显示div ,选中id="no"时,不显示div.怎么做?????<input type="radio" value="true" name="ynRepaly" id="yes" checked="checked"  />
                <label for="ynRepaly-true">是</label>
<input type="radio" value="false" name="ynRepaly" id="no"  /> 
 <label for="ynRepaly-false">否</label>
<div id="show">显示显示</div>

解决方案 »

  1.   


    <script language="javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript">window.onload=function(){
    $("#show").show();
    $("#yes").click(function(){
    $("#no").attr("checked", false);
    $("#show").show();
    });
    $("#no").click(function(){
    $("#yes").attr("checked", false);
    $("#show").hide();
    });
    }</script>
    <input type="radio" value="true" name="ynRepaly" id="yes" checked="checked" />
      <label for="ynRepaly-true">是</label>
    <input type="radio" value="false" name="ynRepaly" id="no" />  
     <label for="ynRepaly-false">否</label>
    <div id="show">显示显示</div>
      

  2.   

    $(function () {
      $(":radio").click(function () {
        if ($(this).attr("id") == "yes" && ($(this).attr("checked") == true || $(this).attr("checked") == "checked")) {
               $("#show").show();
        } else {
               $("#show").hide();
        }
      });
    });
      

  3.   


    <script type="text/javascript" src="JQuery-1.4.js"></script> 
    <script language="javascript" type="text/javascript">
    $(document).ready(function() {
    $(":radio").click(function(){
    if($(this).attr("id")=="yes" && $(this).attr("checked")==true ){ //
    $("#show").show();
    }else{
    $("#show").hide();
    }
    })
    });
    </script>