var name={//object对象 name:'jackson',age:12 //name:表示属性,jackson表示属性name的值 } //console.log(name.name)//输出属性值 //console.log(name['name'])//输出属性值 //console.log(typeof name)//输出类型 for(var key in name){ console.log('key is '+key+' ,value is '+name[key]) //key is name ,value is jackson //key is age ,value is 12 } console.log(!{})//输出false var array=[2,3,4]//定义数组 console.log(array.length) //3 console.log(typeof array)//object array.push("45") console.log(array.length)//4 2.函数 function sun(first,second){ console.log(arguments.length)//输出参数长度 //1 //2 } sun(1); sun("1",2); 3. var username=' jaconsonn' console.log(username.length)// 11 console.log($.trim(username).length)// 9 ,jquery的去空格函数trim 4. $('p').css( { color:'red', borderColor:'#000' }).width(500) 5.$('<div >this is new Tag </div>').appendTo($('body'))//向body中添加元素 6.jquery插件(非常重要) $.fn.display=function(){//定义一个jquery的方法插件,方便调用 return this.each(function(){//返回遍历结果 this.disabled=true;//设置当前元素为不可用 }); } $('input').display();//调用插件