Skip to content

Instantly share code, notes, and snippets.

View ioslh's full-sized avatar
😀

Lianghua ioslh

😀
View GitHub Profile
window.onload=function(){
//获取页面元素
var aBtn=document.getElementsByTagName("button");
var box=document.getElementById("box");
var tip=document.getElementById("tips");
//定义三个函数,用三种方式循环改变背景颜色
var fn=[function(){
//第一种,遍历取出数组中的颜色值
var colors=['yellow','red','black','blue','green'];
var i=0;
window.onload=function(){
var oBtn=document.getElementsByTagName("button")[0];
oBtn.onclick=function(){
changeLineColor(document.getElementById("num").value);
}
changeLineColor();
};
function changeLineColor(num){
var n=Number(num)>0 && Number(num)<6?Number(num):2;
var colors=["yellow","red","blue","green","grey"];
// 传统的方法
window.onload=function(){
var tab=document.getElementById("tab");
var a=tab.getElementsByTagName("a");
var div=tab.getElementsByTagName("div");
for(var i=0;i<a.length;i++){
a[i].index=i;
a[i].onmouseover=function(){
for(var j=0;j<a.length;j++){
a[j].className="";
window.onload=function(){
var table=document.createElement("table");
for(var i=1;i<10;i++){
var tr=document.createElement("tr");
if(i%2==0){
tr.className="dark";
}else{
}
for(var j=1;j<i+1;j++){
var td=document.createElement("td");
define([
'jquery'
], function (
$
) {
var STARTED = false;
@ioslh
ioslh / test.c
Last active August 2, 2016 03:00
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[Bugtags startWithAppKey:@"APP_KEY" invocationEvent:BTGInvocationEventBubble];
return YES;
}
window.Lib = function(){
var h1 = document.createElement('h1')
h1.textContent = 'Hello World'
document.body.appendChild(h1)
}
window.Lib()
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script src="//shadow.elemecdn.com/zcache/gl/god-dev/perf-js@2.1.3/dist/perf.min.js"></script>
@ioslh
ioslh / fake-database.js
Created February 18, 2019 08:37
Fake Database
const fs = require('fs')
class FakeDatabase {
constructor(dbPath) {
this._filePath = dbPath || './data.json'
this._data = JSON.parse(fs.readFileSync(this._filePath))
this._idBase = Math.max.apply(null, this._data.map(i => i.id))
}
_idGen() {
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no,viewport-fit=cover">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;