0

I have a jquery mobile webapp and I'm trying to hide certain fields from the user unless they check a checkbox. It's not working though. Here is what I have so far:

<script type="text/javascript">

$(document).ready(function() {
    $('#mycheckbox').change(function() {
        $('#mycheckboxdiv').toggle();
    });
});
</script>

<fieldset data-role="controlgroup">
<input type="checkbox" name="mycheckbox" id="mycheckbox" value="0" />
</fieldset>
<div id="mycheckboxdiv" style="display:none">
    This content should appear when the checkbox is checked
</div>

nothing happens when I check the box.

4

1 回答 1

0

change() 一般用于 input 或 textarea 输入字段。

对于按钮,您可以使用 .click() 检查点击事件

$("#mycheckbox").click(function() {...
于 2013-09-13T16:27:15.280 回答