How to show hide div upon existing div, existing div should be hide.
<div class="container">
<div class="row">
<input class="abc" type="text" />
</div>
</div>
<div class="container newone">
<div class="row">
<span>some text here</span>
</div>
</div>
.newone{ position:absolute; left:0; right:0; top:0px; display:none;}
You can use the focus
and focusout
events of an input to hide and show a related message using javascript:
var input = document.getElementById('myinput'); var message = document.getElementsByClassName('newone')[0]; input.addEventListener('focus', function() { message.style.display = 'block'; }); input.addEventListener('focusout', function() { message.style.display = 'none'; });
.newone { display:none; }
<div class="container"> <div class="row"> <input class="abc" type="text" id='myinput'/> </div> </div> <div class="container"> <div class="row"> <span>some text here </span> <span>some text here</span> </div> </div> <div class="container newone"> <div class="row"> <span>some text here</span> </div> </div>
this should work
$(function() {
$(".abc").focusin(function() {
$(".newone").show();
}).focusout(function () {
$(".newone").hide();
});
});
You could use addClass
to hide the div using jQuery, Please refer the below code.
$( ".container" ).addClass( "newone" );
For more info please refer the below url
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.