示例代码:
HTML
Name | Type |
---|---|
name; ?> | type; ?> |
JavaScript $('#filter').change(function() { var type = $(this).val(); $('table tbody tr').show(); if(type !== '') { $('table tbody tr').not('[data-type="' + type + '"]').hide(); } });
PHP public function index() { $items = Item::all(); return view('items', compact('items')); }
public function filter(Request $request) { $type = $request->input('type'); $items = Item::where('type', $type)->get(); return view('items', compact('items')); }