-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreadme.txt
More file actions
27 lines (24 loc) · 954 Bytes
/
readme.txt
File metadata and controls
27 lines (24 loc) · 954 Bytes
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
1、获取数组里面的最大值和最小值(其中numbers为对应的数组)
console.log(Math.max.apply(Math,numbers));
console.log(Math.min.apply(Math,numbers));
2、搜索文字高亮
$("#replace").on("click",function(){
var content = $("div[class=article]").text().trim(); //文章内容
var key = $("input[type=text]").val().trim();//关键字
var reg = new RegExp(key,"g");
if(reg.test(content)){
var item = content.replace(reg,function(t){
return "<span class=\"addColor\">"+t+"</span>";//添加样式
});
$("div[class=article]").html(item).show();
}else{
//在不匹配的情况之下清除以前的样式
$("div[class=article]").find("span[class=addColor]").removeClass("addColor");
}
});
3、扩展数组的删除方法
Array.remove = function(array,form,to){
var rest = array.slice((to || form) + 1 || array.length);
array.length = form < 0 ? array.length + form : form;
return array.push.apply(array,rest);
}