复选框选中/取消选中时如何隐藏/显示内容? [英] How to hide/show content when checkbox is checked/unchecked?

查看:586
本文介绍了复选框选中/取消选中时如何隐藏/显示内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为一个客户端创建一个表单,并且已经给我一个任务,在未选中某个复选框时创建一个显示/隐藏效果。

I'm working on a form for a client and he has given me the task to create a show/hide effect when certain checkbox in unselected.

推荐答案

此函数应该:

$("#yourCheckboxID").click(function ()
{
    if ($("#yourCheckboxID").attr("checked"))
    {
        $("#yourDivID").show();
    }
    else
    {
        $("#yourDivID").hide();
    }              
});

它将隐藏或显示特定的 div 基于复选框。我不知道你想要隐藏或显示什么,所以我只是假设一个 div

It will hide or show a specific div based on a checkbox. I wasn't sure exactly what you were trying to hide or show so I just assumed a div.

这篇关于复选框选中/取消选中时如何隐藏/显示内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆