Laravel查看代碼:如何通過點擊各個頁腳動態獲取引導標題值?
<div class="col-sm-12">
@foreach($deviceCategory as $deviceCategories)
<div class="col-sm-4">
<div class="panel panel-default">
<div class="panel-heading">
<div class="col-sm-1">
<div id="deviceId" class="check">{{$deviceCategories-
>deviceCategoryId}}</div>
</div>
<br/>
</div>
<div class="panel-body">
<div class="col-sm-2">
<h5><strong>{{$deviceCategories->deviceCategoryName}}</strong></h5>
<h6><button style="border:none; background-color: transparent;"
disabled></button></h6>
</div>
<div class="col-sm-1" align="center">
<img src="{{asset(Storage::url('public/' . $deviceCategories-
>image))}}" width="200" height="150">
</div>
</div>
<div class="panel-footer" align="right"><a href="" data-
toggle="modal" data-target="#myModal"
class="getDeviceCategoryId">SELL THIS CATEGORY</a></div>
</div>
</div>
@endforeach
</div>
這是我的視圖代碼。在這裏,我動態顯示從db中獲取的值。然後,當我用面板頁腳點擊(即賣掉這個類別)時,我需要提醒面板標題中的相應值(即,{{$ devicesCategories-> deviceCategoryId}})
SCRIPT代碼
<script type="text/javascript">
$(document).ready(function() {
$('.getDeviceCategoryId').click(function() {
var value=$('#deviceId').text();
alert(value);
});
});
這是我試過的腳本代碼。但是我只能得到所有面板頁腳的第一個id值。
我所做的changes.But它提醒沒什麼 –
任何錯誤?你可以在瀏覽器控制檯中檢查JS錯誤 –
@nishanthi:獲取[如何診斷JS錯誤到瀏覽器](http:// www。inmotionhosting.com/support/website/javascript/diagnose-javascript-errors) –