-
Notifications
You must be signed in to change notification settings - Fork 0
/
hide.html
110 lines (110 loc) · 2.89 KB
/
hide.html
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>几种样式隐藏的区别</title>
<script src="jquery.js"></script>
<style>
div {
width: 100px;
height: 100px;
background: red;
margin: 15px;
padding: 10px;
border: 5px solid green;
display: inline-block;
overflow: hidden;
}
.none { display: none; }
.hidden { visibility: hidden; }
.opacity0 { opacity: 0; }
.height0 { height: 0; }
</style>
</head>
<body>
<div class="none"></div>
<div class="hidden"></div>
<div class="opacity0"></div>
<div class="height0">aa</div>
<iframe id="apply" src="flex.html"></iframe>
<script>
$(".none").on("click", function () {
console.log("none clicked");
})
$(".hidden").on("click", function () {
console.log("hidden clicked");
})
$(".opacity0").on("click", function () {
console.log("opacity0 clicked");
})
$(".height0").on("click", function () {
console.log("height0 clicked");
});
$($('#apply')[0].contentWindow.document).find('.item').click(function(){
alert("click on parent")
});
console.time('str');
var str='1234567890',arr=[];
for(var i=0;i<str.length;i++){
arr.push(str.charAt(i))
}
console.timeEnd('str')
console.time('obj');
var str1=new String('1234567890'),arr1=[];
for(var i=0;i<str1.length;i++){
arr1.push(str1.charAt(i))
}
console.timeEnd('obj');
function isPrime(n){if(n==0||n==1){
return false;
}
var bound=Math.floor(Math.sqrt(n));
for(var i=2;i<=bound;i++){
if(n%i==0){return false}
}
return true;
}
MAX=100;
console.time('normal');
(function normal(){
var count=0;
for(var i=2;i<=MAX;i++){
if(isPrime(i)){
count++;
}
}
console.log('finish,total '+count)
})();
console.timeEnd('normal');
console.time('timeout');
(function timeout(){
var count=0;
var jobs=10,numperjob=Math.ceil(MAX/jobs);
function counts(start,end){
for(var i=start;i<=end;i++){
if(isPrime(i)){
count++;
}
}
}
var start, end,timer,finished=0;
function manage(){
if(finished==jobs){
window.clearTimeout(timer);
}else{
start=finished*numperjob+1;
end=Math.min((finished+1)*numperjob,MAX);
timer=window.setTimeout(function(){
counts(start,end);
finished++;
manage();
},100)
}
}
manage();
console.log('finish,total '+count)
})();
console.timeEnd('timeout');
</script>
</body>
</html>