Your question is very vague, I'm not sure if the input points to a specific div, whether it will have multiple inputs and multiple divs.
However the answer would be something like:
You can use the .style
or .className 'property:
style:
window.onload = function() {
var div = document.querySelector("div[class='tooltip.right']");
var input = document.querySelector(".form-control");
input.onclick = function() {
div.style.display = "block";
};
input.onblur = function() {
div.style.display = "none";
};
};
div[class="tooltip.right"] {
display: none;
}
<input class="form-control">
<div class="tooltip.right">Olá mundo</div>
className:
window.onload = function() {
var hideClass = /(^|\s)hide(\s|$)/;
var div = document.querySelector("div[class*='tooltip.right']");
var input = document.querySelector(".form-control");
input.onclick = function() {
div.className = div.className.replace(hideClass, " ");
};
input.onblur = function() {
div.className += " hide";
};
};
.hide {
display: none;
}
<input class="form-control">
<div class="tooltip.right hide">Olá mundo</div>
Note:
I recommend that you do not use classes with point class="tooltip.right"
, the point is a delimiter to identify the classes in the CSS selectors, it would be better something like:
<div class="tooltip.right hide">Olá mundo</div>
Or if you are using the dot as separator and tooltip and right are two different classes, then the correct one to separate in HTML is the space, like this:
<div class="tooltip right hide">Olá mundo</div>