Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I want to hide a div when one input is in focus in Angular 4 or Angular 6

Tags:

angular

I want to hide a div when an input is in focus.

I tried to hide another div by ng-class however I really don't know how to implement it.

<div class="form-group col-md-9">
 <input id="notes" placeholder="Notes" formControlName="notes" />
  <div id="another-div">Test div which is hidden when notes input is in focus
 </div>
</div>
like image 854
pmh Avatar asked Oct 19 '25 09:10

pmh


1 Answers

Well you can do this with css1 only:

input:focus+div{ display:none; }
<div class="form-group col-md-9">
  <input id="notes" placeholder="Notes" formControlName="notes" />
  <div id="another-div">Test div which is hidden when notes input is in focus
  </div>
</div>

Note: 1. This requires a div after the input.

like image 54
Jai Avatar answered Oct 21 '25 22:10

Jai