本帖最后由 ThisTimed 于 2014-02-27 16:37:01 编辑

解决方案 »

  1.   

    你判断下传递的值进行勾选,除非下注册的事件不就好了$(document).ready(function(){
        $(".setcf").change(function(){
            switch($(".setcf:checked").val()){
            case "0":
                $("#condfield").hide();
                $("#nextactive").show();
                break;
            case "1":
                $("#nextactive").hide();
                $("#condfield").show();
                break;
            default:
                break;
            }
        });
    var s=location.search//获取url后面?的参数
    if(s.indexOf('1')!=-1)$(".setcf[value='1']").attr('checked',true).trigger('change');
     });
      

  2.   

    感谢解答。我是用Java后端,页面直接用EL取的,这怎么弄??<input class="setcf" type="radio" name="tab_wactive.havecondfield" value="1" <c:if test="${wa.havecondfield==1}">checked</c:if>>是
    <input class="setcf" type="radio" name="tab_wactive.havecondfield" value="0" <c:if test="${wa.havecondfield==0}">checked</c:if>>否
      

  3.   

    <html xmlns="http://www.w3.org/1999/xhtml"><head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
    <title>无标题文档</title>
    <script type="text/javascript" src="jquery-1.4.2.min.js"></script>
    </head><body>
    <input type="checkbox" class="setcf" value="1" /> 选项一 是
    <input type="checkbox" class="setcf" value="0" /> 选项二 否
    <input type="checkbox" class="setcf" value="1" /> 选项三 是
    <a href="" id="nextactive">是显示</a>
    <a href="" id="condfield" style='display:none'>是隐藏</a>

    <script type="text/javascript">


    $(document).ready(function(){
        $('[value]').click(function(){
         //console.log($(this).val());
         if($(this).val() == 1 && $(this).attr('checked')){
        
         $("#condfield").hide();
                $("#nextactive").show();
         }else{
        
         $("#condfield").show();
                $("#nextactive").hide();
         }
        })
     });
    </script>
    </body></html>
      

  4.   

    服务器端设置过直接trigger触发下事件就好了$(document).ready(function(){
        $(".setcf").change(function(){
            switch($(".setcf:checked").val()){
            case "0":
                $("#condfield").hide();
                $("#nextactive").show();
                break;
            case "1":
                $("#nextactive").hide();
                $("#condfield").show();
                break;
            default:
                break;
            }
        });
    $(".setcf:checked").trigger('change');
     });