随笔分类 -  javascript

摘要:我们知道一个网址 自己的网址, 不同页面也有自己id网址, 我们经常会做一些, 把网址送入到后台。 但是后台再处理的 不认识比如 换行啊 等特殊符号的 ? var url = “http://www.itast.cn?name=cz” 所以我们要实现编码,然后再传到后台。 encodeURIComp 阅读全文
posted @ 2019-12-25 17:26 杨小越 阅读(145) 评论(0) 推荐(0)
摘要:<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> </head> <body> <input type="file" name="" id="File"/><span></span> <!-- 阅读全文
posted @ 2019-12-25 09:43 杨小越 阅读(796) 评论(0) 推荐(0)
摘要:var PI = 1213.141592653; // 常量大写 console.log(PI.toFixed(2)); console.log(parseInt(PI * 100) / 100); var str = PI + ""; // 因为数字没法进行字符操作 先转换 console.log 阅读全文
posted @ 2019-12-25 09:34 杨小越 阅读(1654) 评论(0) 推荐(1)
摘要:1.str.chartAt(index) 返回相应位置字符(参数: 字符位置) 2.str.charCodeAt(index) 返回相应位置字符unicode编码(参数: 字符位置) 3.str.length 4.str.indexOf(substr) str.lastIndexOf(substr) 阅读全文
posted @ 2019-12-24 18:53 杨小越 阅读(185) 评论(0) 推荐(0)
摘要:1. push() 后面推进去 push() 方法可向数组的末尾添加一个或多个元素,并返回新的长度。 var arr =[1,3,5] → arr.push(7,9) → 结果变成 : [1,3,5,7,9]; 2. unshift() 从数组的前面放入 unshift() 方法可向数组的开头添加一 阅读全文
posted @ 2019-12-20 14:25 杨小越 阅读(162) 评论(0) 推荐(0)
摘要:<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <script> let a = '2'; switch (a) { case 1: conso 阅读全文
posted @ 2019-12-20 14:12 杨小越 阅读(287) 评论(0) 推荐(0)
摘要:1.oninput 事件在元素值发生变化是立即触发, onchange 在元素失去焦点时触发; 2.onchange 事件也可以作用于<select> 元素。 注:IE 6 7 8 支持的 : onpropertychange而不是oninput。 阅读全文
posted @ 2019-12-20 13:51 杨小越 阅读(683) 评论(0) 推荐(0)
摘要:1 <!doctype html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Document</title> 6 <style> 7 section { 8 width: 300px; 9 margin: 100px 阅读全文
posted @ 2019-12-20 13:40 杨小越 阅读(482) 评论(0) 推荐(0)
摘要:1 <!doctype html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Document</title> 6 </head> 7 <script> 8 window.onload = function () { 阅读全文
posted @ 2019-12-20 12:58 杨小越 阅读(447) 评论(0) 推荐(0)
摘要:<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <style> # 阅读全文
posted @ 2019-12-20 11:36 杨小越 阅读(495) 评论(0) 推荐(0)
摘要:<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> <script> window.onload = function () { var txt = document.getElementByI 阅读全文
posted @ 2019-12-17 18:17 杨小越 阅读(656) 评论(0) 推荐(0)
摘要:1. 函数的 arguments 对象并不是一个数组,但访问单个参数的方式与访问数组元素的方式相同; 2. arguments对象的长度是由实参个数而不是形参个数决定的。 <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> < 阅读全文
posted @ 2019-12-17 16:33 杨小越 阅读(401) 评论(0) 推荐(0)
摘要:var fun = new Function("var a = 10; var b = 20; alert(a+b)"); fun(); 阅读全文
posted @ 2019-12-17 16:26 杨小越 阅读(87) 评论(0) 推荐(0)
摘要:1. 利用 -0 ,*1 , /1 ,都可以转换 2 利用Number( ) ,parseInt(), parseFloat() 阅读全文
posted @ 2019-12-17 16:09 杨小越 阅读(557) 评论(0) 推荐(0)
摘要:1. 利用 !! 2.利用 Boolean() 阅读全文
posted @ 2019-12-17 16:07 杨小越 阅读(822) 评论(0) 推荐(0)
摘要:1. + "" 加了引号的都是字符型 console.log(typeof (false+'')); console.log(typeof (new Date()+'')); 2.利用String(); 转换为字符型 console.log(typeof String(false));console 阅读全文
posted @ 2019-12-17 16:05 杨小越 阅读(825) 评论(0) 推荐(0)
摘要:隐式的全局变量:没有声明var的变量也是全局变量。 注意:严格模式下报错! var a = 1 function func() { a = b = 2 } func() alert(a) alert(b) 阅读全文
posted @ 2019-12-17 15:34 杨小越 阅读(282) 评论(0) 推荐(0)
摘要:变量的命名规则: 1.变量命名必须以字母或是下标符号”_”或者”$”为开头。 2.变量名长度不能超过255个字符。 3.变量名中不允许使用空格。 4.不用使用脚本语言中保留的关键字及保留符号作为变量名。 5.变量名区分大小写。(javascript是区分大小写的语言) 阅读全文
posted @ 2019-12-17 15:29 杨小越 阅读(3618) 评论(0) 推荐(0)
摘要:console.log(null==undefined); // true console.log(null undefined); // false console.log(null+10); // 10 console.log(undefined+10); // NaN 阅读全文
posted @ 2019-12-17 14:35 杨小越 阅读(137) 评论(0) 推荐(0)
摘要:<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> </head> <body> <script> console.log(parseInt(19.11)); console.log(parse 阅读全文
posted @ 2019-12-17 14:29 杨小越 阅读(479) 评论(0) 推荐(0)