随笔分类 - javascript
个人学习
摘要:<script type="text/javascript"> //反转字符口串 //abcdefg //转大写 //1.split() 把字符串切割成数组 //2.reverse() 反转数组 //3.join() 把数组链接成字符串 //4.toUpperCase() 字符串转大写 var st
阅读全文
摘要:<script type="text/javascript"> //字符串常用方法(不改变原始字符串) <ES5 var str='hello world' //1.charAt() 按照索引查找字符串的内容,并返回 //语法:字符串.charAt(需要查找的索引 ) //返回值:对应索引上的字符串
阅读全文
摘要:<script type="text/javascript"> var arr=['hello','world','Jack','Rose','world'] //1.indexOf() 查看数组中是否存在该内容 //第一种使用方式 //语法:数组.indexOf(需要查找的内容) //不改变原始数
阅读全文
摘要:<script type="text/javascript"> var arr=['hello','world','sql','linux'] //5.concat() 对数组进行拼接 可拼接多个数组 //语法:数组.concat(拼接的内容) //不改变原始数组 //数组添加在末尾 //返回值:原
阅读全文
摘要:<script type="text/javascript"> //数组常用方法1(只能是数组使用) var arr=[1,2,3,4,5] //1.push() 向数组中添加数据 //语法 数组.push(需要添加的数据) //直接改变原始数组 //放在数组末尾 //返回值 :添加数据后数组长度
阅读全文
摘要:<body> <!-- 判断数组中是否存在60这个元素 返回布尔类型 --> <script type="text/javascript"> var arr=[1,2,5,6,4,8,4,4,4,5] function has(arr,n){ //判断数组里面有没有n这个数据 //先假设数组里面没有
阅读全文
摘要:<style type="text/css"> span{ border: double 2px orangered; background-color: orange; } b{ color: red; } b:hover{ background-color: yellow; font-size:
阅读全文
摘要:<body> <div style="margin:0 auto"> <h2>用户注册</h2> <form name="regform" action=""> <div class="mystyle">用户名:<input type="text" value="" id="user" name="
阅读全文
摘要:<body> <div style="margin:0 auto"> <h2>用户注册</h2> <form name="regform" action=""> <div class="mystyle">用户名:<input type="text" value="" id="user" name="
阅读全文
摘要:<script type="text/javascript"> var arr2=[23,56,8,4,6,9,2,0,13,55,94,344,3] /* 选择排序 * 假设外层循环变量 * 里层循环变量开始时外层变量+1 * 交换外层变量 */ for ( var i=0;i<arr2.leng
阅读全文
摘要:<script type="text/javascript"> /* btn.onclick=function() { console.log('我被点击了') }*/ //报错 // 浏览器事件绑定在windown上// 表示当所有资源加载完毕后触发 window.onload=function(
阅读全文
摘要:<style type="text/css"> *{ margin: 10px; padding: 5px; box-sizing: border-box; } span{ /*width: 200px; height: 100px;*/ display: inline-block; text-al
阅读全文
摘要:<body> <div style="width: 300px; height: 100px; border: dotted red 5px; border-radius: 20px; box-sizing: border-box; font:20px/30px '方正舒体'; color:gree
阅读全文
摘要:<script type="text/javascript"> /* 三资自幂数 从100~999 每一个的 三次幂 的 和 这个数相等 123 1*1*1+2*2*2+3*3*3 */ // 判断一个数字是不是三次自幂数 var num=153 var a=parseInt(num/100) va
阅读全文
摘要:<script type="text/javascript"> document.writeln('打印出1000~2000年中所有的闰年,并以每行四个数的形式输出<br />') //做一个计数器 var count=1 for (var i=1000;i<=2000;i++) { if(i%4
阅读全文
摘要:<script type="text/javascript"> document.writeln(' 输入年份、月份,显示当月的天数'+'<br>') var year= parseInt(prompt('请输入一个年份')) var month= parseInt(prompt('请输入一个月份'
阅读全文
摘要:<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title></title> <style type="text/css"> *{padding: 0;margin: 0;} #box{ width: 200px;height: 200px;
阅读全文
摘要:<script type="text/javascript"> /* 1~100以内3的倍数 */ document.writeln('1~100以内3的倍数: '+'<br />') for (var i=1;i<=100;i++) {// 判断i能被3整除 if (i%3 0) { docume
阅读全文