English 中文(简体)
如果无线电台用 j子检查,则显示盒子
原标题:Show box if radio button checked using jQuery

我有以下法典:

    <fieldset>
        <legend>Do you currently have SolidWorks</legend>

        <ul>
            <li><label for=""><input type="radio" name="solidworks" value="Yes" id="rdYes" /> Yes</label></li>
            <li><label for=""><input type="radio" name="solidworks" value="No" id="rdNo" /> No</label></li>
        </ul>
    </fieldset>

    <fieldset id="boxReseller" style="display:none;">
        <legend>Who is your SolidWorks reseller?</legend>
        <ul>
            <li><label for=""><input type="radio" name="reseller" value="Cad Connect" /> Cad Connect</label></li>
            <li><label for=""><input type="radio" name="reseller" value="Cadtek" /> Cadtek</label></li>
            <li><label for=""><input type="radio" name="reseller" value="CCSL" /> CCSL</label></li>
            <li><label for=""><input type="radio" name="reseller" value="Innova" /> Innova</label></li>
            <li><label for=""><input type="radio" name="reseller" value="NT CAD/CAM" /> NT CAD/CAM</label></li>
            <li><label for=""><input type="radio" name="reseller" value="Solid Engineer" /> Solid Engineer</label></li>
            <li><label for=""><input type="radio" name="reseller" value="Solid Solutions Ireland" /> Solid Solutions Ireland</label></li>
            <li><label for=""><input type="radio" name="reseller" value="Solid Solutions Management" /> Solid Solutions Management</label></li>
            <li><label for=""><input type="radio" name="reseller" value="TMS Scotland" /> TMS Scotland</label></li>
        </ul>

    </fieldset>

我想要做的是隐藏第二个领域,而另一个领域是缺席,如果一个人选择。 是的,箱子将出现,如果他们选择不选择,则箱子将再次隐藏。

谁能帮助? 感谢。

最佳回答

Ref Nick Craver - 尼斯办法,尽管它比下文更便于使用

  $("input[name= solidworks ]").change(function() {
    $("#boxReseller").toggle();
 });​​​​​​
$("input[name= solidworks ]:checked").change(); //trigger correct state onload

通过将gle角作为野生卡(不界定你喜欢的任何术语) 我发现它的工作效率更高。 尼斯:

问题回答

你可以这样做:

$("input[name= solidworks ]").change(function() {
  $("#boxReseller").toggle(this.value == "Yes");
});​​​​​​
$("input[name= solidworks ]:checked").change(); //trigger correct state onload

您可以在此上标出一栏,并尝试。 The “Yes” edition here

<>Demo

http://jsfiddle.net/Wpt3Y/"rel=“nofollow> http://jsfiddle.net/Wpt3Y/

jQuery(function(){
        jQuery("input[name=solidworks]").change(function(){          


            if ($(this).val() == "Yes") {
            jQuery("#boxReseller").slideDown()
            }
            else {
            jQuery("#boxReseller").slideUp();
            }                                                            
       });
});

$(document).ready(function() {
    $("input[name=solidworks]").change(function() {
        if ($this).val() == "Yes") {
            $("#boxReseller").slideDown( fast );
        }
        else {
            $("#boxReseller").hide( fast );
        }
    })
})

类似情况(如果有打字,我的咖啡树脂则:

 <fieldset id="fs">
        <legend>Do you currently have SolidWorks</legend>

        <ul>
            <li><label for=""><input type="radio" name="solidworks" value="Yes" id="rdYes" /> Yes</label></li>
            <li><label for=""><input type="radio" name="solidworks" value="No" id="rdNo" /> No</label></li>
        </ul>
    </fieldset>

有了更好的办法,但我的咖啡不是这样。 一旦我获得我的精子,我就会ed。

<script>attr( checked , checked )
     $("#fs:checkbox").click(function(){
              if($("#rdYes:checked").attr( checked , checked ))
              {
                 $("#boxReseller").css( display ,  block ); })
              }          
     });
</script>




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签