2017-03-06 35 views
0

我已經研究了很多關於這計算器但沒有解決方案,爲我的工作動態表的警告框行ID ..顯示在被點擊複選框之後

<div class="ibox-content"> 

         <div class="table-responsive"> 
          <table class="table table-striped table-bordered table-hover dataTables-example tdiv" id="resultTable" > 
           <thead> 
            <tr> 
             <th></th>  
             <th>Company Name</th> 
             <th>Niche</th> 
             <th>Date Added</th> 
            </tr> 
           </thead> 
           <tbody> 

            @foreach($companies as $company) 
            <tr class="clickable-row" id="{{$company->id}}"> 
             <td align="center"><input type="checkbox" class="i-checks" name="input[]"></td> 
             <td>{{ $company->name }}</td> 
             <td>{{ $company->niche }}</td> 
             <td>{!! date('M j, Y', strtotime($company->created_at)) !!}</td>  
            </tr> 
            @endforeach 


           </tbody> 

     </table> 
    </div> 

我的JavaScript:

<script type="text/javascript"> 
    $("#resultTable").click(function(){ 
    var closestTr = $(':checkbox:checked').closest('tr').attr('id'); 
    alert(closestTr); 
    }); 
</script> 

這是因爲我使用ibox還是什麼?我不知道發生了什麼事,請幫忙。

回答

0

答案原來是很簡單的......

所有我需要做的是改變的Javascript的類複選框的...

這樣的:

$(document).ready(function() { 
    $('.i-checks').click(function(event) { 
    var companyId = this.id; 
    console.log(companyId); 
    alert(companyId); 
    }); 
});