
js
魑.魅.魍.魉
一个IT行业的小菜鸟
展开
-
正则表达式
正则表达式正则的作用语法标记限定符定位符选择(圆括号的副作用,相关的匹配会被缓存,在第一个选项前加?:)正则表达式运算符优先级模式C#JavaJavaScriptPythonRuby正则的作用测试字符串的模式(验证电话号码,邮箱)替换文本提取字符串语法标记*匹配零个或多个字符(前面的那一个字符出现零次或多次)?匹配零个或一个字符(前面的那一个字符出现零次或一次)^匹配字符串的开始位...原创 2018-12-17 21:53:15 · 125 阅读 · 0 评论 -
JS-键盘控制特效
vx = 10; vy = 10; sx = 0; sy = 0; document.onkeydown =function (event) { code = event.keyCode; switch (code) { case 37: //左 sx -=v...原创 2019-06-15 22:19:16 · 258 阅读 · 0 评论 -
JS-右键菜单
<style> #menu { display: none; position: absolute; top: 0px; left: 0px; } ul{ /*去点*/ list-styl...原创 2019-06-15 07:03:13 · 130 阅读 · 0 评论 -
JS-弹力球动画的实现
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>This is test</title><style> *{ margin: 0px; padding: 0px; ...原创 2019-06-14 23:30:34 · 367 阅读 · 0 评论 -
JS-进度条的实现(只是一个页面效果)
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>This is test</title><style> #main{ width: 100%; height: 30p...原创 2019-06-14 22:43:39 · 327 阅读 · 0 评论 -
JS-鼠标键盘事件
hobjs = document.getElementsByTagName('span'); for ( i = 0; i<hobjs.length;i++){ //鼠标进入事件 hobjs[i].onmouseenter = function () { this.style.backgroundColor = '#ccc' ...原创 2019-06-14 19:26:30 · 141 阅读 · 0 评论 -
JS-获取标签
document.getElementById()//根据ID获取标签 document.getElementsByClassName()//根据类名称获取标签 document.getElementsByName()//根据名称获取标签 document.getElementsByTagName()//根据标签名称获取标签...原创 2019-06-14 12:57:33 · 108 阅读 · 0 评论 -
JS-绑定事件的方法
<h1><span ID="cli">单击事件</span></h1><h1><span onclick="clic('asas')">单击事件</span></h1><h1><span >单击事件</span></h1> cli = docume...原创 2019-06-14 11:53:34 · 314 阅读 · 0 评论 -
JS-四种高度
h = document.documentElement.clientHeight;//可视高度 alert(h); h = document.documentElement.scrollHeight;//屏幕的总高度 alert(h); window.onscroll= function () { h = document.documentElem...原创 2019-06-14 10:36:55 · 208 阅读 · 0 评论 -
JS-读秒的三秒钟之后跳转
i = 3; setInterval(function () { html = --i; if (html==0){ location.href = 'index.html'; } time = document.getElementById('time'); time.innerHT...原创 2019-06-14 08:45:22 · 208 阅读 · 0 评论 -
JS-超时器
//两秒钟以后跳转 document.write('两秒钟以后跳转'); setTimeout(function () { location = 'index.html'; },2000);原创 2019-06-14 08:39:02 · 507 阅读 · 0 评论 -
JS-计数器
i = 0; function start(){ sobj = setInterval(function () { document.title = ++i; },1000) } function stop(){ clearInterval(sobj); } start(); s...原创 2019-06-14 08:29:44 · 343 阅读 · 0 评论 -
JS-数组排序
arr = [10,5,3,56,9,79]; arr.sort(show); function show(i,j) { // return i-j;//从小到大排序 return j-i;//从大到小排序 } alert(arr);原创 2019-06-14 07:46:01 · 122 阅读 · 0 评论 -
JS-去除左右空格
name = ' Linux '; function trim(str) { return str.replace(/(^\s*)|\s*$/g,''); } alert(name.length); alert(trim(name).length);原创 2019-06-13 11:30:36 · 1150 阅读 · 0 评论 -
JS-截取文件名称或路径
name = "/www/web/lampym/index.php"; pos = name.lastIndexOf('/');//'/所在的最后位置' str = name.substr(pos+1)//截取文件名称字符串 url = name.substr(0,pos)//截取路径字符串 alert(str); alert(url);...原创 2019-06-13 11:29:56 · 6062 阅读 · 0 评论 -
JS-实时表的实现
setInterval(function () { dobj =new Date(); year = dobj.getFullYear(); month = dobj.getMonth()+1; month = month>9 ? month :'0'+month; day = dobj.getDate(...原创 2019-06-13 11:19:13 · 228 阅读 · 0 评论 -
PHP-JSON-AJAX
JSONstring json_encode ( $value [, $options = 0 ] )value: 要编码的值。该函数只对 UTF-8 编码的数据有效。options:由以下常量组成的二进制掩码:JSON_HEX_QUOT, JSON_HEX_TAG, JSON_HEX_AMP, JSON_HEX_APOS, JSON_NUMERIC_CHECK,JSON_PRETTY_P...原创 2019-07-01 23:59:20 · 121 阅读 · 0 评论