05 2020 档案
摘要://匿名函数// var f = function (){// alert("helloworld");// }// f(); new Date() 获取当前的时间 new Date(yyyy,month,dd hh:mm:ss) 获取某一年的时间 new Date(yyyy,mth,dd,hh,m
阅读全文
摘要://1.先让用户输入两个数m,n,写一个方法,打印m行,n列星星组成的矩形 function a(x,y){ for(i=1;i<=m;i++){ for( j=1;j<=n;j++){document.write("*");} document.write("</br>"); }} var m=p
阅读全文
摘要://求1-100的和// var a=1;// var sum=0;// while(a<=100){// sum=sum+a;// a++;// }// document.write(sum);//逆序打印数组// var brr=[4,5,6,7,8];// var j=brr.length-1
阅读全文
摘要:// document.write((1=="1")+'<br>');//只比较内容,不比较类型// document.write((1 "1")+'<br>');//比较两边内容和类型// //&&两边都对才对,||两边一个对就对,!取反// var f=(1==2?"错误":"正确");// d
阅读全文
摘要:/* 显示定义 */// var a=1;// alert(a); 弹出1// alert("a");//值,弹出a// var b;// b=2;// alert(b);// /* 隐式定义变量 */// c=10;// alert(c);// var be=true;// alert(be);
阅读全文
摘要:<button id="add">添加</button> <div> <input type="text" class="a" value="0"> <input type="text" class="b" value="0"> <div class="c">求和:</div> </div> $('
阅读全文
摘要:1、隐藏/显示, $(‘div’).hide();//隐藏 <div id="fang" style="width: 100px;height: 100px;background-color: #0000FF;display: block;"> </div> <button id="b" type=
阅读全文
摘要:1、引入<script src=”jquery.js”></script> 2、选择器:同css选择器; $(‘#id’);$(‘p’);$(‘[href=”#”]’);$(‘.class’) 3、事件 $(‘p’).click(function(){});//点击事件 hover(function
阅读全文
摘要:parentNode:父级节点 <div id="a1">父<p id="a2">孩子</p></div> var i=document。getElementById(‘a2’).parentNode; console.log('i');//会查找到a2元素的父节点 childNodes:子级节点集
阅读全文
摘要:点击事件,点击div时触发一个弹窗 <div id="a1">点击</div> js document.getElementById('a1').onclick=function(){ alert('点击') } 如果写在head里面需要加window.onload,会最后执行js window.o
阅读全文