随笔分类 - JS
摘要:setTimeout(fun,time)表示time毫秒后执行fun函数。 SetInterval(fun,time)表示每隔time毫秒执行fun函数一次。 setInterval是间隔执行 setTimeout是延迟执行
阅读全文
摘要:function ClassManager(){}; ClassManager.prototype.addClass=function(str){ console.log("class"+str+" added."); return this; } manager.addClass('A').add
阅读全文
摘要:function Person(name){ this.name=name; } function Student(name,className){ this.className=className; Person.call(this,name);//调用别的构造器 } var mike=new S
阅读全文
摘要:function Person(){ var agrs=arguments; if(typeof args[0]==='object' && args[0]){ //如果第1个参数为对象,且不为空(即不为0、''、null) if(args[0].name){this.name=args[0].na
阅读全文
摘要:function Person (name,age) { this.name=name; this.age=age; this.hi1=function() { console.log('name:'+this.name+',age:'+this.age+'.'); } } Person.proto
阅读全文
摘要:function Person(){}undefinedtypeof Person"function" //Person是一个构造函数p=new Person();Person {} //p是Person函数构造的一个实例,是一个Person{}对象p.__proto__ //__proto__属性
阅读全文
摘要:1 function BaseClass() { 2 //父类对象showMsg方法 3 this.showMsg=function(){ 4 alert("BaseClass::showMsg"); 5 } 6 //父类对象的baseShowMsg方法 7 this.baseShowMsg=fun...
阅读全文
摘要:.表示任意字符(除换行等控制字符外) \d表示数字 \w表示数字、字母或下划线 \s表示空格、TAB、换行符、换页符 \S表示非\s /\w\w\w/.test('a_1')true 范围符号 [A-F]:A-F之间的字符 [^A-F]:A-F以外的字符 ^Hi:表示Hi开头 end$:表示以end
阅读全文
摘要:hasOwnProperty('x') Javascript 中的false、0、null、undefined和空字符串对象 在Javascript中,我们经常会接触到题目中提到的这5个比较特别的对象——false、0、空字符串、null和undefined。这几个对象很容易用错,因此在使用时必须得
阅读全文
摘要:1 //通过自面量创建数组 2 var arr1=[1,'abc',true,{a:1}]; 3 for(i in arr1){ 4 alert(arr1[i]+":"+(typeof arr1[i])); 5 } 6...
阅读全文
摘要:function is_number(field,div_id)//div_id是显示错误的div的ID{ var patt=new RegExp("^[0-9]{1,2}$");//建立正则表达式对象patt with(field){ if(patt.test(value)==false){//...
阅读全文
摘要:(非原创) 用户注册 用户名: 密 码: 确认密码: 警告:禁止粘贴 身份证号: 性 别:男女 出生日期: YYYY-MM-DD或者YYYY/MM/DD 籍 贯: 爱 好:音乐 篮球 旅游 睡觉 * 全选 反选 邮 箱: 手机号码: 自我介...
阅读全文
摘要:1、定义一个函数//参数top为触发全选的checkbox对象function selAll(top) {var items = document.getElementsByTagName("input");//获取所有的input标签对象for ( var i = 0; i
阅读全文
摘要:getElementById getElementsByName getElementsByTagName 大概介绍 getElementById ,getElementsByName ,getElementsByTagName 后两个是得到集合,byid只是得到单个对象 getElement...
阅读全文
摘要:js获取表单值的两种方法function ff(){//var a=document.getElementById("user").value; //方法1 // user 是指: 中的ID ~~id='user'//var a=document.form.user1.value; //方法2 /...
阅读全文
摘要:获取Html元素:obj=document.getElementById("id")设置Html元素文本内容:obj.innerHTML="text"改变Html元素的样式:obj.style.color="red"obj.style.visibility="hidden|visible"添加Htm...
阅读全文
浙公网安备 33010602011771号