kk Blog —— 通用基础


date [-d @int|str] [+%s|"+%F %T"]
netstat -ltunp
sar -n DEV 1

js异步、同步ajax

html

1
<input type='button' id='modify_{$table}' onClick="noModify('{$table}', 'modify_{$table}')" value='test'>

js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function noModify(table, bid)
{
	var idadd = 'is_add_' + table;
	var param = {};
	param[idadd] = '1';
	htmlobj=$.ajax({
		type: 'post',
		url: test.php,
		async: true,
		data: param,
		success: function(html) {
			document.getElementById(bid).disabled = 'disabled';
		}
	});
}

页面内容已修改,您确定要离开?

html

1
2
3
4
<input style='display:none' name='beforeunload' id='beforeunload' value='0'>

<button id='{$idpre}_edit' type='button' class=submit onclick=enable_all()>编辑</button>
<input id='{$addidpre}_submit' class='submit' type='submit' value='提交' onclick=submit_it()>

js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function enable_all() {
	var b = document.getElementById('beforeunload');
	if (b !== null)
		b.value = 2;
}

function submit_it() {
	var b = document.getElementById('beforeunload');
	if (b !== null)
		b.value = 1;
}

window.addEventListener("beforeunload", function(e) {
	var val = document.getElementById('beforeunload').value;
	if (val > 1) {
		var confirmationMessage = "您是否要离开 - 您输入的数据可能不会被保存。";
		(e || window.event).returnValue = confirmationMessage; // Gecko and Trident
		return confirmationMessage; // Gecko and WebKit});
	}
});

table行随鼠标移动变色示例

https://www.jiangweishan.com/article/svg1486310400790.html

1、设计表格

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<body class="html_body">
<div class="body_div">
<table id="tab">
	<tr style="background: #000000;color: #FFFFFF;font-weight: bolder;">
		<th>工号</th>
		<th>姓名</th>
		<th>年龄</th>
		<th>性别</th>
	</tr>
	<tr>
		<td>2014010101</td>
		<td>张峰</td>
		<td>56</td>
		<td>男</td>
	</tr>
	<tr>
		<td>2014010102</td>
		<td>李玉</td>
		<td>42</td>
		<td>女</td>
	</tr>
	<tr>
		<td>2014010103</td>
		<td>王珂</td>
		<td>36</td>
		<td>男</td>
	</tr>
	<tr>
		<td>2014010104</td>
		<td>张钰</td>
		<td>31</td>
		<td>女</td>
	</tr>
	<tr>
		<td>2014010105</td>
		<td>朱顾</td>
		<td>44</td>
		<td>男</td>
	</tr>
	<tr>
		<td>2014010106</td>
		<td>胡雨</td>
		<td>35</td>
		<td>女</td>
	</tr>
	<tr>
		<td>2014010107</td>
		<td>刘希</td>
		<td>30</td>
		<td>男</td>
	</tr>
	<tr>
		<td>2014010108</td>
		<td>孙宇</td>
		<td>45</td>
		<td>女</td>
	</tr>
	<tr>
		<td>2014010109</td>
		<td>谷雨</td>
		<td>33</td>
		<td>男</td>
	</tr>
	<tr>
		<td>2014010110</td>
		<td>科宇</td>
		<td>45</td>
		<td>女</td>
	</tr>
</table>
</div>
</body>

2、设计样式

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
.html_body .body_div {
	width: 1340;
	height: 595;
}
.body_div {
	font-size: 12px;
	background-color: #CCCCCC;
}
.tr_odd {
	background-color: orange;
}
.tr_even {
	background-color: aqua;
}
.mouse_color {
	background-color: green;
}
#tab {
	border: 1px #FF0000 solid;
	text-align: center;
	width: 100%;
	height: 100%;
}

3、设计JS

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//设置奇数行背景色
//$("#tab tr:odd").find("td").addClass("tr_odd");
$("#tab tr:odd").addClass("tr_odd");
//设置偶数行背景色
$("#tab tr:even").addClass("tr_even");

// 鼠标移到的颜色
$("#tab tr").mouseover(function() {
	$(this).addClass("mouse_color");
});

// 鼠标移出的颜色
$("#tab tr").mouseout(function() {
	$(this).removeClass("mouse_color");
});