HTML
<div class="dep-adm-inp" <?php if(!empty($adm_f) || $adm_f != "") echo "style='display:block'"; ?> id="fees-inp">
<label>Admission Fees(<i class="fa fa-inr"></i>)</label>
<div class="input-group">
<span class="input-group-addon remove-inp"><i class="fa fa-close"></i></span>
<input type="text" class="form-control expected" value="<?php if(!empty($adm_f)) echo $adm_f; ?>" placeholder="Amount Expected">
<input type="text" class="form-control paid" value="<?php if(!empty($adm_f)) echo $adm_f; ?>" placeholder="Paid Amount">
</div>
</div>
Javascript
$(".dep-adm-inp").hide();
the div is hidden when page loads but if the php variable is not empty then i want to show the div when.
set the class variable dep-adm-inp
as hidden by default in css. If the variable $adm_f
is not empty, set style='display:block;'
. With this logic you don't need to call the statement $(".dep-adm-inp").hide();
in your javascript. This way the div will be shown only if the variable $adm_f
is not empty.
.hide()
method sets display:none;
on your element. You can override it by setting display: block!important;
(or whatever your display
property is) in CSS:
setTimeout(() => { $('.item').hide(); }, 2000);
.container { display: flex; } .item { width: 200px; height: 100px; background-color: darkgoldenrod; margin: 10px; } /* This makes .item visible even after .hide() */ .item-visible { display: block!important; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="container"> <div class="item item-visible">Will be visible</div> <div class="item">Will be hidden</div> </div>
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.