Javascript 在单选按钮上显示/隐藏按钮单击jquery

Javascript 在单选按钮上显示/隐藏按钮单击jquery,javascript,jquery,html,Javascript,Jquery,Html,我有两个按钮和两个单选按钮 钮扣 1 btnErp 2 Btngogle 单选按钮 1.远程日志 2 rdioErp 如果我单击RDIOOGLE,则BTNGOGLE应该可见,btnerp应该隐藏;如果我单击rdioerp,则btnerp应该可见,BTNGOGLE应该隐藏 我执行了以下代码,但它不起作用 Jquery 好的,整理一下,让它工作起来: <script> $(document).ready(function() { $("#btnerp").hi

我有两个按钮和两个单选按钮

钮扣

1 btnErp

2 Btngogle

单选按钮

1.远程日志

2 rdioErp

如果我单击RDIOOGLE,则BTNGOGLE应该可见,btnerp应该隐藏;如果我单击rdioerp,则btnerp应该可见,BTNGOGLE应该隐藏

我执行了以下代码,但它不起作用

Jquery


好的,整理一下,让它工作起来:

<script>
      $(document).ready(function() {
        $("#btnerp").hide();
        $("#rdiogoogle").click(function() {
          $("#btngoogle").show();
          $("#btnerp").hide();
        });
        $("#rdioerp").click(function() {
          $("#btngoogle").hide();
          $("#btnerp").show();
        });
      });

</script>
<div style="margin-top:20px;" class="spaceradio">
  <span>
            <input type="radio" id="rdiogoogle" name="logintype" value="Google Login" /><span style="font-weight:bold; font-size:17px; font-family:Verdana; margin-left:20px; color:black;">Google Login</span>
  </span>
</div>
<div style="margin-top:20px;" class="spaceradio spacer">
  <span>
            <input type="radio" id="rdioerp" name="logintype" value="ERP Login" /><span style="font-weight:bold; font-size:17px; font-family:Verdana; margin-left:20px; color:black;">ERP Login</span>
  </span>
</div>
<div class="imagediv" style="">

  <input id="btngoogle" type="button" alt="Google Login" width="100" height="34" class="btnspacer" value="BtnGoogle" />
  <input id="btnerp" type="button" class="btn btn-default btnspacererp" width="200" height="34" value="Login" />
</div>

基本上,您的jQuery选择器有一个输入错误。

好的,稍微整理一下,使其正常工作:

<script>
      $(document).ready(function() {
        $("#btnerp").hide();
        $("#rdiogoogle").click(function() {
          $("#btngoogle").show();
          $("#btnerp").hide();
        });
        $("#rdioerp").click(function() {
          $("#btngoogle").hide();
          $("#btnerp").show();
        });
      });

</script>
<div style="margin-top:20px;" class="spaceradio">
  <span>
            <input type="radio" id="rdiogoogle" name="logintype" value="Google Login" /><span style="font-weight:bold; font-size:17px; font-family:Verdana; margin-left:20px; color:black;">Google Login</span>
  </span>
</div>
<div style="margin-top:20px;" class="spaceradio spacer">
  <span>
            <input type="radio" id="rdioerp" name="logintype" value="ERP Login" /><span style="font-weight:bold; font-size:17px; font-family:Verdana; margin-left:20px; color:black;">ERP Login</span>
  </span>
</div>
<div class="imagediv" style="">

  <input id="btngoogle" type="button" alt="Google Login" width="100" height="34" class="btnspacer" value="BtnGoogle" />
  <input id="btnerp" type="button" class="btn btn-default btnspacererp" width="200" height="34" value="Login" />
</div>

基本上,jQuery选择器中有一个输入错误。

您需要在代码中使用不同的逻辑,请尝试以下操作:

$(document).ready(function () {

     $("input[name=logintype]").change(function(){

        if($("#rdiogoogle").is(':checked')){
            $("#btgoogle").show();
            $("#btnerp").hide();
        }else if($("#rdioerp").is(':checked')){
            $("#btngoogle").hide();
            $("btnerp").show();
        }
    });
 });

您需要在代码中使用不同的逻辑,请尝试以下操作:

$(document).ready(function () {

     $("input[name=logintype]").change(function(){

        if($("#rdiogoogle").is(':checked')){
            $("#btgoogle").show();
            $("#btnerp").hide();
        }else if($("#rdioerp").is(':checked')){
            $("#btngoogle").hide();
            $("btnerp").show();
        }
    });
 });

在调用document.ready上的“click”方法时,请确保您的写入ID正确。您可以使用以下代码-

 $(document).ready(function () {

           $("#btnerp").hide();
            $("#btngoogle").hide();
            $("#rdiogoogle").click(function () {
                $("#btngoogle").show();
                $("#btnerp").hide();
            });
            $("#rdioerp").click(function () {
                $("#btngoogle").hide();
                $("#btnerp").show();
            });
        });

在调用document.ready上的“click”方法时,请确保您的写入ID正确。您可以使用以下代码-

 $(document).ready(function () {

           $("#btnerp").hide();
            $("#btngoogle").hide();
            $("#rdiogoogle").click(function () {
                $("#btngoogle").show();
                $("#btnerp").hide();
            });
            $("#rdioerp").click(function () {
                $("#btngoogle").hide();
                $("#btnerp").show();
            });
        });

我希望你想要这样的东西

      <script>
    $(function(){
    $('#btngoogle').hide();
    $('#btnerp').hide();

    $('#rdiogoogle').on('click',function(){

   $('#btngoogle').show();
   $('#btnerp').hide();
    });

    $('#rdioerp').on('click',function(){

    $('#btngoogle').hide();
    $('#btnerp').show();
     });

     });

    </script>

因为通过jQuery,您可以隐藏您的按钮……因此无需将其添加到css中,我希望您需要类似的内容

      <script>
    $(function(){
    $('#btngoogle').hide();
    $('#btnerp').hide();

    $('#rdiogoogle').on('click',function(){

   $('#btngoogle').show();
   $('#btnerp').hide();
    });

    $('#rdioerp').on('click',function(){

    $('#btngoogle').hide();
    $('#btnerp').show();
     });

     });

    </script>

因为通过jQuery,您可以隐藏您的按钮…因此无需将其添加到css中

是否将jQuery引用链接到您的页面jQuery位于同一页面检查您的“btngoogle”,它是btgoogle或btngoogle,一旦您修复了id名称,它就会运行correctly@trying... 编辑是否已将jquery引用链接到您的页面jquery在同一页面检查您的“btngoogle”,它是btgoogle或btngoogle,一旦您修复id名称,它就会工作correctly@trying... 编辑