用过JavaScript的实现表格的隔行变色,鼠标经过加亮至少需要20行以上的代码,而是用jQuery只需要短短几行的代码。

td {padding:6px 11px;border-bottom:1px solid #95bce2;vertical-align:top;text-align:center;} td * {padding:6px 11px; } /偶数行 tr 加上背景色/ tr.even td {background:#ecf6fc;} /这个将是鼠标高亮行的背景色/
tr.over td {background:#bcd4ec;}

$(document).ready(function(){
	$('.pm tr').mouseover(function(){
		$(this).addClass('over');}).mouseout(function(){$(this).removeClass('over');
	});
	$('.pm tr:even').addClass('even');
});



  
值得一提的是上面代码中

//本来应该这么写
$(".pm tr").mouseover(function(){     
          $(this).addClass("over");})  
$(".pm tr").mouseout(function(){     
          $(this).removeClass("over"); }) 
//但是我们写成了:
$('.pm tr').mouseover(function(){
		$(this).addClass('over');}).mouseout(function(){$(this).removeClass('over');
	});
//说明jQuery是链式的行为  

Nginx 自动禁止爬虫IP采集

### 背景最近我们有一个公开服务提供给客户查询关键词的热度值,由于这个API做在官方网站上,自然没有用户登陆,也没有很高查询成本,所以设计上没有任何鉴权无法进行身份认定,于是就被一个爬虫开了超高并发请求,直接后端的AWS Tomcat CPU被用尽,导致无法响应。爬虫显然...… Continue reading

Redis原子性事务Lua应用

Published on June 28, 2020