show and hide div tag based on checkbox selection using javascript

Solutions on MaxInterview for show and hide div tag based on checkbox selection using javascript by the best coders in the world

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
pinned-register now
showing results for - "show and hide div tag based on checkbox selection using javascript"
Valentín
06 Aug 2020
1<input class="coupon_question" type="checkbox" name="coupon_question" value="1" onchange="valueChanged()"/>
2
3<script type="text/javascript">
4    function valueChanged()
5    {
6        if($('.coupon_question').is(":checked"))   
7            $(".answer").show();
8        else
9            $(".answer").hide();
10    }
11</script>
12