简体   繁体   中英

show & hide div by checkbox

please say me, what's wrong ? we have many checkbox. OnClick any checkbox div "catdiv" must show with animate (bottom,0 %).

If checked checkbox is <1, "catdiv" must hide with animate...

<script>
$(':checkbox').on('change', function() {
$("#catdiv").animate ({bottom: "0%"), 500 );
});
</script>

You are using ID but maybe you need to use class ?

<script>
$(':checkbox').on('change', function() {
$(".catdiv").animate ({bottom: "0%"), 500 );
});
</script>

Try this:

$('input[type="checkbox"]').click(function() {
    $(".catdiv").animate({bottom: "0%"}, 500 );
});
  • You can use $(this).is(':checked') to check whether the check box is checked or not.
  • For the .catdiv , it should have " absolute " as position . You can use its ID or class to select it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM