【问题标题】:jquery onclick on input radio to show/hide input textjquery onclick 输入单选显示/隐藏输入文本
【发布时间】:2017-08-11 16:20:12
【问题描述】:

我正在尝试通过单选按钮选择切换(隐藏/显示)输入文本,但它不起作用。

怎么了? http://jsfiddle.net/mwwj9vvt/ 谢谢:-)

onclick="$('#idprezzoCSSClass').css('display', 'yes');"

我不明白为什么会出现问题:https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js 评论和使用不同的 jquery 版本/资源它可以工作,但我需要 ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js https://jsfiddle.net/6psb8c73/

【问题讨论】:

  • 你需要使用'display','block'..没有像'yes'这样的属性
  • 你在混合 jQuery 和纯 JS
  • 还有这个……
  • onclick="$('#idprezzoCSSClass').css('display', '');"
  • 用“block”代替“yes”还是不行:-(

标签: jquery css onclick


【解决方案1】:

参考下面的代码,可能对你有帮助

<script>
$(document).ready(function(){
$("#hide").click(function(){
    $("p").hide();
});
$("#show").click(function(){
    $("p").show();
});
});
</script>

<button id="hide">Hide</button>
enter code here

【讨论】:

  • 它只有在我不添加 [code] 时才有效code.jquery.com/mobile/1.0rc1/jquery.mobile-1.0rc1.min.css" />
猜你喜欢
  • 2013-07-23
  • 2020-05-05
  • 1970-01-01
  • 1970-01-01
  • 2014-06-20
  • 1970-01-01
  • 2012-08-11
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多