我正在尝试创建一个表,我可以通过单击它的最后一个单元格上的按钮删除一行,但它不起作用。我将它移动到一个测试项目(没有laravel),它可以工作,但不适用于刀片laravel。我已经尝试了尽可能多的方法,但仍然无法弄明白。
<link rel="stylesheet" type="text/css" href=" {{asset('public/css/cart.css')}}">
<script type="text/javascript">
$("td.cart_delete").on("click", function () {
alert("On click");
$(this).closest("tr").remove();
});
</script>
@extends('layouts.layout')
@section('content')
<section id="cart_items">
<div class="container">
<div class="breadcrumbs">
<ol class="breadcrumb">
<li><a href="#">Trang chủ</a></li>
<li class="active">Giỏ hàng</li>
</ol>
</div>
<div class="table-responsive cart_info">
<table class="table table-condensed">
<thead>
<tr class="cart_menu">
<td class="image">Mặt hàng</td>
<td class="description">Mô tả</td>
<td class="price">Giá</td>
<td class="quantity">Số lượng</td>
<td class="total">Thành tiền</td>
<td></td>
</tr>
</thead>
<tbody>
<tr>
<td class="cart_product">
<a href=""><img src="images/cart/one.png" alt=""></a> <!-- Cái này chứa ảnh của sp -->
</td>
<td class="cart_description">
<h4><a href="">Tên sản phẩm</a></h4> <!-- Tên sản phẩm -->
<p><a>Phan Thanh Tuyên</a></p>
</td>
<td class="cart_price">
<p>120.000 VNĐ</p> <!-- Giá -->
</td>
<td class="cart_quantity"> <!-- Số lượng -->
<div class="cart_quantity_button">
<!-- <a class="cart_quantity_up" href=""> + </a> -->
<button class="add-btn">+</button>
<input class="cart_quantity_input" type="text" name="quantity" value="1" autocomplete="off" size="2" id="so_luong"> <!-- Đây cần thay đổi số lượng sản phẩm mua theo csdl -->
<!-- <a class="cart_quantity_down" href=""> - </a> -->
<button class="minus-btn">-</button>
</div>
</td>
<td class="cart_total">
<p class="cart_total_price">$59</p>
</td>
<td class="cart_delete">
<!-- <a class="cart_quantity_delete" href=""><i class="fa fa-times"></i></a> Đây là nút delete một sản phẩm trong giỏ hàng. Chưa biết nên để <button> hay <a>. Cái này tùy cách xử lý của ô -->
<button class="quantity_delete"><i class="fa fa-times"></i></button>
</td>
</tr>
<tr>
<td class="cart_product">
<a href=""><img src="images/cart/two.png" alt=""></a>
</td>
<td class="cart_description">
<h4><a href="">Colorblock Scuba</a></h4>
<p>Web ID: 1089772</p>
</td>
<td class="cart_price">
<p>$59</p>
</td>
<td class="cart_quantity">
<div class="cart_quantity_button">
<button class="add-btn">+</button>
<input class="cart_quantity_input" type="text" name="quantity" value="1" autocomplete="off" size="2">
<button class="minus-btn">-</button>
</div>
</td>
<td class="cart_total">
<p class="cart_total_price">$59</p>
</td>
<td class="cart_delete">
<!-- <a class="cart_quantity_delete" href=""><i class="fa fa-times"></i></a> -->
</td>
</tr>
<tr>
<td class="cart_product">
<a href=""><img src="images/cart/three.png" alt=""></a>
</td>
<td class="cart_description">
<h4><a href="">Colorblock Scuba</a></h4>
<p>Web ID: 1089772</p>
</td>
<td class="cart_price">
<p>$59</p>
</td>
<td class="cart_quantity">
<div class="cart_quantity_button">
<button class="add-btn">+</button>
<input class="cart_quantity_input" type="text" name="quantity" value="1" autocomplete="off" size="2">
<button class="minus-btn">-</button>
</div>
</td>
<td class="cart_total">
<p class="cart_total_price">$59</p>
</td>
<td class="cart_delete">
<!-- <a class="cart_quantity_delete" href=""><i class="fa fa-times"></i></a> -->
</td>
</tr>
</tbody>
</table>
</div>
</div>
</section> <!--/#cart_items-->
<section id="do_action">
<div class="container">
<div class="row">
<!-- <div class="col-sm-6">
</div> -->
<div class="col-sm-6">
<div class="total_area">
<ul>
<li>Cart Sub Total <span>$59</span></li>
<li>Eco Tax <span>$2</span></li>
<li>Shipping Cost <span>Free</span></li>
<li>Total <span>$61</span></li>
</ul>
<a class="btn btn-default update" href="{{url('cart')}}">Update</a>
<a class="btn btn-default check_out" href="{{url('checkout')}}">Check Out</a>
</div>
</div>
</div>
</div>
</section><!--/#do_action-->
@endsection
感谢您的帮助!
答案 0 :(得分:0)
假设你是jQuery正在工作。
在这里,
<link rel="stylesheet" type="text/css" href=" {{asset('public/css/cart.css')}}">
@extends('layouts.layout')
@section('content')
<section id="cart_items">
<div class="container">
<div class="breadcrumbs">
<ol class="breadcrumb">
<li><a href="#">Trang chủ</a></li>
<li class="active">Giỏ hàng</li>
</ol>
</div>
<div class="table-responsive cart_info">
<table class="table table-condensed">
<thead>
<tr class="cart_menu">
<td class="image">Mặt hàng</td>
<td class="description">Mô tả</td>
<td class="price">Giá</td>
<td class="quantity">Số lượng</td>
<td class="total">Thành tiền</td>
<td></td>
</tr>
</thead>
<tbody>
<tr>
<td class="cart_product">
<a href=""><img src="images/cart/one.png" alt=""></a> <!-- Cái này chứa ảnh của sp -->
</td>
<td class="cart_description">
<h4><a href="">Tên sản phẩm</a></h4> <!-- Tên sản phẩm -->
<p><a>Phan Thanh Tuyên</a></p>
</td>
<td class="cart_price">
<p>120.000 VNĐ</p> <!-- Giá -->
</td>
<td class="cart_quantity"> <!-- Số lượng -->
<div class="cart_quantity_button">
<!-- <a class="cart_quantity_up" href=""> + </a> -->
<button class="add-btn">+</button>
<input class="cart_quantity_input" type="text" name="quantity" value="1" autocomplete="off" size="2" id="so_luong"> <!-- Đây cần thay đổi số lượng sản phẩm mua theo csdl -->
<!-- <a class="cart_quantity_down" href=""> - </a> -->
<button class="minus-btn">-</button>
</div>
</td>
<td class="cart_total">
<p class="cart_total_price">$59</p>
</td>
<td class="cart_delete">
<!-- <a class="cart_quantity_delete" href=""><i class="fa fa-times"></i></a> Đây là nút delete một sản phẩm trong giỏ hàng. Chưa biết nên để <button> hay <a>. Cái này tùy cách xử lý của ô -->
<button class="quantity_delete" id="c_delete"><i class="fa fa-times"></i></button>
</td>
</tr>
<tr>
<td class="cart_product">
<a href=""><img src="images/cart/two.png" alt=""></a>
</td>
<td class="cart_description">
<h4><a href="">Colorblock Scuba</a></h4>
<p>Web ID: 1089772</p>
</td>
<td class="cart_price">
<p>$59</p>
</td>
<td class="cart_quantity">
<div class="cart_quantity_button">
<button class="add-btn">+</button>
<input class="cart_quantity_input" type="text" name="quantity" value="1" autocomplete="off" size="2">
<button class="minus-btn">-</button>
</div>
</td>
<td class="cart_total">
<p class="cart_total_price">$59</p>
</td>
<td class="cart_delete">
<!-- <a class="cart_quantity_delete" href=""><i class="fa fa-times"></i></a> -->
</td>
</tr>
<tr>
<td class="cart_product">
<a href=""><img src="images/cart/three.png" alt=""></a>
</td>
<td class="cart_description">
<h4><a href="">Colorblock Scuba</a></h4>
<p>Web ID: 1089772</p>
</td>
<td class="cart_price">
<p>$59</p>
</td>
<td class="cart_quantity">
<div class="cart_quantity_button">
<button class="add-btn">+</button>
<input class="cart_quantity_input" type="text" name="quantity" value="1" autocomplete="off" size="2">
<button class="minus-btn">-</button>
</div>
</td>
<td class="cart_total">
<p class="cart_total_price">$59</p>
</td>
<td class="cart_delete">
<!-- <a class="cart_quantity_delete" href=""><i class="fa fa-times"></i></a> -->
</td>
</tr>
</tbody>
</table>
</div>
</div>
</section> <!--/#cart_items-->
<section id="do_action">
<div class="container">
<div class="row">
<!-- <div class="col-sm-6">
</div> -->
<div class="col-sm-6">
<div class="total_area">
<ul>
<li>Cart Sub Total <span>$59</span></li>
<li>Eco Tax <span>$2</span></li>
<li>Shipping Cost <span>Free</span></li>
<li>Total <span>$61</span></li>
</ul>
<a class="btn btn-default update" href="{{url('cart')}}">Update</a>
<a class="btn btn-default check_out" href="{{url('checkout')}}">Check Out</a>
</div>
</div>
</div>
</div>
</section><!--/#do_action-->
<script type="text/javascript">
$("td.cart_delete").on("click", function () {
alert("On click");
$(this).closest("tr").remove();
});
</script>
@endsection
点击前,
点击