0
我在頁面上有一系列下拉按鈕,並試圖用按鈕的ID來觸發單個函數。爲什麼我的函數沒有被調用?在下拉菜單中使用按鈕觸發jquery
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle btn-sm btn-block" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Options
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="lists/{{ $list['id'] }}/details">Edit Details</a>
<a class="dropdown-item" href="#">Convert to...</a>
<a class="dropdown-item" href="#" id= "{{ $list['id'] }}" class="copy-row">Copy</a>
</div>
</div>
和JS:
$('.copy-row').click(function(e) {
e.preventDefault();
var token = $('meta[name="csrf-token"]').attr('content');
var id = $(this).attr('id');
$.ajax({url: '/lists/' + id, data: {_token:token}, type: 'PUT'})
window.location.reload();
});