您的位置:首页 > Web前端 > JavaScript

js相关知识整理

2015-07-02 00:00 816 查看
摘要:css中的定位:绝对定位、相对定位。jquery的异步加载ajax事件

知识点一:定位position
css的定位属性:position:static(静态)|relative(相对)|absolute(绝对)|fixed(固定)
绝对定位:以其已定位的祖先元素为参考点。
---已定位祖先元素:元素有fixed、relative、absolute修饰。
相对定位:以其在文档流中的原始位置为参考点。
知识点二:jQueryajax事件
碰到一个问题:
如下代码,jQuery中的ajaxStart、ajaxStop方法不运行。
?

1

2

3

4

5

6
$(
"#infos"
).ajaxStart(
function
(){


$(
this
).html(
"加载中···"
).show();

});

$(
"#infos"
).ajaxStop(
function
(){


$(
this
).html(
"加载完成!"
).hide();

});
原因:query1.8以上只能绑定到$(document)上,而我使用的是2.1.4版本,所以一直不能运行。
?

1

2

3

4

5

6
$(document).ajaxStart(
function
(){


$(
"#infos"
).html(
"加载中···"
).show();

});

$(document).ajaxStop(
function
(){


$(
"#infos"
).html(
"加载完成!"
).hide();

});
处理方法:更换jquery版本或改用document

知识点三:css相关问题
1、Chrome中文界面下默认会将小于12px的文本强制按照12px显示,可通过加入CSS属性-webkit-text-size-adjust:none;解决.
案例一:定时器
?

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
<!doctypehtml>

<html>

<head>


<metacharset=
"UTF-8"
>

<title>Document</title>

<scripttype=
"text/javascript"
>

window.onload=
function
(){


var
send=document.getElementById(
'send'
),


times=60,


timer=
null
;


send.onclick=
function
(){


//计时开始


send.disabled=
true
;


if
(timer){


clearInterval(timer);

timer=
null
;


}


timer=setInterval(
function
(){

if
(times>0){

times--;


send.value=times+
"秒后重试"
;

}

else
{

clearInterval(timer);

send.value=
"发送验证码"
;

times=60;

send.disabled=
false
;

}


},1000);




}

}

</script>

</head>

<body>

<inputtype=
"button"
id=
"send"
value=
"发送验证码"
/>

</body>

</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: