2016-01-07 30 views
1

在這裏,我通過ajax獲得結果。 如果我從ajax得到結果,我想隱藏div。 如果通過ajax得到結果,我想隱藏下面的div。如果我得到結果,要隱藏ajax調用的div

這裏是我的代碼,

$("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("---"); 
        }       
     } 
    }); 
}); 

我的HTML部分,

<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> 

在這裏,我想隱藏這個div如果我得到如上的結果。 我們該怎麼做?

+2

使用'$( 「#selecttime」)。隱藏()' –

+0

這工作..謝謝Parth ...! –

+0

回調成功已棄用,請改用done() – nfort

回答

3

你必須使用

//this will do display:none in style 
$("#selecttime").hide(); 

和展示使用

//this will do remove display:none from style 
$("#selecttime").show(); 

請檢查Document

5

請嘗試如下。使用display屬性值none而不是hidden

document.getElementById('selecttime').style.display = "none"; 

或者你可以使用jqueryhide()功能類似以下。

$("#selecttime").hide();