-3
<div class="ddown">
    <button class="dbtn">ABC</button>
</div>       

I want to make this div hide/show when a checkbox is checked/unchecked, how can I achieve this?

Bentaye
  • 9,403
  • 5
  • 32
  • 45

3 Answers3

3

try The following code

<input type="checkbox" ng-model="chkCondition">
<div class="ddown" ng-show="chkCondition">
    <button class="dbtn">ABC</button>
</div>

<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<body>

<div ng-app="">
    Check to show/Hide a div:
    <input type="checkbox" ng-model="chkCondition">
<div class="ddown" ng-show="chkCondition">
    <button class="dbtn">ABC</button>
</div>  
</body>
</html>
Faraz Babakhel
  • 654
  • 5
  • 14
2

html

<input type="checkbox" ng-model="isChecked" />
<div ng-show="isChecked" class="ddown">
   <button class="dbtn">ABC</button>
</div>
sebu
  • 2,824
  • 1
  • 30
  • 45
0

Try with using ng-if to avoiding DOM element creation.

<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<body>

<div ng-app="">
    <input type="checkbox" ng-model="isChecked">
<div class="ddown" ng-if="isChecked">
    <button class="dbtn">ABC</button>
</div>  
</body>
</html>
Ramesh Rajendran
  • 37,412
  • 45
  • 153
  • 234