1.JSJQ课程期末复习之复习JS

1.加强for

   var b=new Array(10);
    var a=["aaa","bbb"];
    for(var i in a){

   }

2.continue和break的区别

continue本次循环continue关键字下面不执行了,可以继续循环(跳本次循环,继续本次循环)
break直接跳出循环

3.常见系统函数

var a=parseInt("str");//转int
          parseFloat("3.21")
          isNaN(xxx);

4.加载后执行的函数

   <div onload="aaa()"><div> 
    <div onmouseover="aaa()"><div> 
  
   //onmouseover 鼠标在某个元素  之前没有这样写过...
   //onchange 域的值改变// input

5.字符串

   str.indexOf('a')!=-1 //字符串存在a
       alert("abc".substring(0,1));//1  //切分字符串
  1. bom(browser object model) 功能 弹出跳转窗口
  1. window—>history(用户访问过的url信息)
    ------------->document(dom) -->link form anchor(锚点)
    -------------->location(当前url 跳转到某个页面)
                window.location="http://xxx" 

7.window(可以不写出来)

 var aa=prompt("11");
	if(aa=="11"){
		console.log(aa);
		close()
	}
   window.prompt("aaa")//提示框功能+一个输入框,返回输入内容字符串
    .alert("aaa");//提示框,
    .confirm("确认删除?");//确认框 确定取消返回值 true,false
    .close();         //关闭当前任务栏的窗口      
    .open('./aa.html');// open("./aa.html","","height=380,width=320,toolbar=0");//没有工具栏
                               //全屏  open("./aa.html","","fullscreen=yes",);
    setTimeout(function(){},1000)//延时任务.只执行一遍
    setInterval(function(){},1000)//定时任务,多少时间不停间隔执行函数

8.引入的js window对象共享

比如
aa.js文件(写了script src引入bb.js)
bb.js(代码可以使用window对象和document对象)

9.history对象(访问过的url记录)
.back();//对象列表的前一个url地址
.forward()//下一个
.go(1) // ==forward()

10.location(地址的操作和得到地址数据)

host 得url和端口号
hostname 主机名
href 直接跳转页面

          reload(); //刷新页面
   <a href="javascript:location.href='xxx.html'"></a>#使用js
   <a href="xxx.html"></a> #使用html代码
  <a href="javascript:location.reload()"></a>
  <a href="javascript:location.back()"></a> #返回点击的上一个页面
      #简化
  <a href="javascript:jump('aaa.html')"></a>
      function jump(url){
           location.href="url"
    }

11.document对象

  1. #判断页面是否为url进入
var ref=document.referrer;//跳转前的页面
console.log(ref);

if(ref==""){
	
	console.log("不是登录页面进入,5秒跳转");
	document.write("<h2>不是</h2>");
	setTimeout(function(){
		location.href='aa.html'
	},5000);
}
  1. getElementById().innerHTML=“XXX”; //改元素里面的html代码
    getElementByClass();
    getElementByName(“season”); //标签的name属性
    getElementByTargName(“input”); //多个就得到一个数组
  1. 与后面知识的联系,只操作不改
   document.getElementsById('xx')[num].value=10#可得value,原始js需要重新修改页面的值,绑定不用
                     getElementById
                     getElementsByName("xxx")//根据标签的name得到值,使用多个input标签...
         xxx.innerHTML=xxx;

13.js对象

1.Date对象
var date=new Date();//替换 setepber 10,2023,10:10:10
date.getDate();//日
getDay();//星期0-6
getHours();//0-23
getMinutes();//0-59 Seconds0-59 Month0-11 FullYear4位
getTime(); //1970年1月1日以来的时间戳 毫秒数

2.Math对象
            .ceil(25.0001); //26  向上取整 0.1--->1
            .floor(25.5); //向下取整25
            .round(25.5) //四舍五入26
            .random()*98 +2; //返回[2,99)   random返回[0,1)

14.定时函数

 setTimeOut("myfunc()",1000);//隔多久调用只有1次,前面函数必须要字符串
 var inter=setInterval("myfunc()",1000);//间隔多久调用一次
  clearInterval(inter);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值