Reputation: 357
Here, I am getting result through ajax. I want to hide div if I get the result from ajax. The below div that I want to hide if get the result through the ajax.
Here is my code,
$("button").click(function(){
var dateselect=$("#dateselect").val();
var userselect = $("#employee").val();
$.ajax({
type: 'GET',
url: "<?php base_url() ?>manage_attendance/listing",
data:'dateselect='+dateselect+'&userselect='+userselect,
dataType: "json",
success: function(data) {
$('.clkin_time').html(data.result);
if(data.clkout_result != "0000-00-00 00:00:00") {
$('.clkout_time').html(data.clkout_result);
//document.getElementById('selecttime').style.display = "hidden";
}
else
{
$('.clkout_time').html("---");
}
}
});
});
My html part is,
<div id="selecttime">
<label class="col-lg-4 control-label">Select Time</label>
<div class="input-group date col-lg-2" id="datetimepicker5" style="display:inline-flex;">
<select id="time_date1" class="form_control" name="time_date1">
<?php
for($i=00;$i<=23;$i++)
{
echo '<option value='.$i.'>'.$i.'</option>';
}
?>
</select>
<select id="time_date2" class="form_control" name="time_date2">
<?php
for($i=00;$i<=59;$i++)
{
echo '<option value='.$i.'>'.$i.'</option>';
}
?>
</select>
<select id="time_date3" class="form_control" name="time_date3">
<?php
for($i=00;$i<=59;$i++)
{
echo '<option value='.$i.'>'.$i.'</option>';
}
?>
</select>
</div>
</div>
Here, I want to hide this div if I get the result as above. How can we do this?
Upvotes: 1
Views: 73
Reputation: 3832
You have to use
//this will do display:none in style
$("#selecttime").hide();
and for show use
//this will do remove display:none from style
$("#selecttime").show();
Please check Document
Upvotes: 3
Reputation: 20740
Try like following. Use display
attribute value none
instead of hidden
.
document.getElementById('selecttime').style.display = "none";
Or you can use jquery
hide()
function like following.
$("#selecttime").hide();
Upvotes: 5