-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
  • 8,857
  • 4
  • 30
  • 41

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
  • 644
  • 4
  • 13
2

html

<input type="checkbox" ng-model="isChecked" />
<div ng-show="isChecked" class="ddown">
   <button class="dbtn">ABC</button>
</div>
sebu
  • 2,546
  • 1
  • 22
  • 40
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
  • 35,211
  • 40
  • 143
  • 222