JQuery(一)

it2022-05-05  63

在网页中引用javaScript的方式使用typeof判断值类型String类型的属性和方法如何创建数组,数组的常用属性和方法#如何创建数组运输符号条件结构常用系统函数和自定义函数window对象常用的属性和方法(弹窗、open、close、定时函数)location、history对象的属性和方法document对象js内置对象js操作dom对象     1.【在网页中引用javaScript的方式】 1.内部js,直接使用<script>标签 2.外部js,指定<script>的src属性 3.直接写在html的标签中(一般极少代码时使用):<input οnclick="javascript:alert('欢迎');">   2.【使用typeof判断值类型】 变量→类型 undefined→undefined number→number String→String boolean→boolean null、引用类型(对象、函数、数组)→object   3.【String类型的属性和方法】 length属性 indexOf(字符串,要查找的字符串); 查找某个字符串在字符串中首次出现的位置 charAt(位置); 返回指定位置的字符串 toLowerCase(); toUpperCase(); substring(指定索引1,指定索引2);

 

//html中 substring(index1,index2);返回在index1和index2之间的字符串,不包括index2对应的字符 //java中 substring(index1,index2);返回在index1和index2之间的字符串,包括index2对应的字符 //c#中 substring(index1,length);length代表截取字符串的长度 split(根据什么字符串分割);将字符串为字符串数组     4.【如何创建数组】 var 数组名 = new Array(size); var 数组名 = new Array("xx","xx"); var 数组名 = new Array(2); 数组名[0]="xx"; 数组名[1]="xx";

  

数组属性:length 方法:join(分隔符);把数组的所有元素放入一个字符串,并用分隔符连接 sort();排序 push();添加一个 或多个元素,返回新的数组长度   5.【运算符号】 ==比较值,===比较值和类型   6.【程序结构】 for(变量  in  对象){         //代码 } var fruit = ["apple","orange"]; for(var i in fruit){ document.write(fruit[i]+"<br/>"); }

 

7.【常用系统函数和自定义函数】 parseInt("num1","num2");   parseFloat();isNaN(); 调用函数:事件名="函数名(); "     8.【window对象常用的属性和方法】 属性: history访问过的urlllacation当前的urlscreen只读属性 方法: prompt() alert() confirm() close() open() setTimeout() setInterval()    9.【location、history对象的属性和方法】 history对象:back()、faward()、go() location对象:   host设置或返回主机名、url端口号hostname设置或返回当前url主机名href设置或返回完整的urlreload()重新加载当前文档replace()替换当前文档 用法: <a href="javascript:history:back()"></a>

  

10.【document的对象和属性】 referrer返回载入当前文档的url(如果不是通过超链接访问的,则为null)url getElementById() getElementByName() getElementByTagName() write()向文档写文本、html表达式、js代码     11.【js内置对象】 1.date对象 2.math对象 3.定时函数 var t = setInterval("renovate()",1000); var w = setTimeout("renovate()",1000); clearTimeout(w); clearInterval(t);

12.【js操作dom对象】

parentNode() childNodes()返回集合,childNodes[i]firstChild() lastChild() nextSibling() previousSibling() firstElementChild() lastElementChild() nextElementSibling() previousElementSibling() nodeName nodeValue nodeType getAttribute("") setAttribute("","") createElement(tagName)tagName是标签类型A.append(B)把B节点追加到A节点结尾insertBefore(A,B)把A节点插入B节点前cloneNode(node) removeChild(node) replaceChild(new,old)   children()用来查找所有直接子节点   Dom中节点有三种类型:元素、文本、属性。 基本选择器:标签xzq、类xzq、idxzq、并集xzq、全局xzq 层次选择器:后代、子xzq、相邻元素xzq、同辈xzq。

 

转载于:https://www.cnblogs.com/wzdnwyyu/p/11169076.html


最新回复(0)