js相关知识整理

知识点一:定位position

css的定位属性:position:static(静态)|relative(相对)|absolute(绝对)|fixed(固定)

绝对定位:以其已定位的祖先元素为参考点。

---已定位祖先元素:元素有fixed、relative、absolute修饰。

相对定位:以其在文档流中的原始位置为参考点。

知识点二:jQuery ajax事件

碰到一个问题:

如下代码,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
<!doctype html>
<html>
<head>
     <meta charset= "UTF-8" >
<title>Document</title>
<script type= "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>
<input type= "button"  id= "send"  value= "发送验证码"  />
</body>
</html>

转载于:https://my.oschina.net/u/2357991/blog/473631

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值