I want to change the background of a div that has an "input-group-addon" class, when I click in the input element:
<div class="form-group col-sm-12 col-md-5">
<label class="sr-only" for="exampleInputEmail">Email address</label>
<div class="input-group" >
<div class="input-group-addon">
<img src="pictures/email.png" alt="Email" />
</div>
<input type="email" class="form-control" id="exampleInputEmail" placeholder="Email Adress" onclick="changeBackground()">
</div>
</div>
I create javascript file background.js:
function changeBackground() {
var el = document.getElementsByClassName('input-group-addon');
el.style.backgroundColor = "#cc0c8e";
}
and I inserted it at the end of the html file:
<script src="js/background.js"></script>
But it doesn't work. I had to make a mistake, but I did not see it... Thank you in advance.