实现网页与数据库的连接,并进行删除操作
今天主要使用VS Code编写代码,接下来会对代码进行详细解读,以下为源代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>动态表格</title>
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
<style>
/* 标签选择器 */
table{
border: 1px solid #444;
/* 合并边框 */
border-collapse: collapse;
width: 400px;
text-align: center;
}
td,th{
border: 1px solid #444;}
</style>
<script>
//设置基础路径
var baseURL = 'http://localhost:8899';
//事件代理
$(function(){
$('tbody').on('click','button',function(event){
console.log(this);
// console.log(event.target);
// console.log(event.currentTarget);
console.log($(this));
// console.log(this.flag);
// console.log($(this).attr('flag'));
var id = $(this).attr('flag')