javascript簡潔ないくつかの関数

664 ワード

 
  
//
function myDate(time){
var d = new Date(time);
this.y=d.getFullYear();
this.m=d.getMonth();
this.d=d.getDate();
this.h=d.getHours();
this.m=d.getMinutes();
this.s=d.getSeconds();
}
// DOM
function createDOM(e,p){
var el=document.createElement(e);
if(!p)
p=document.body;
p.appendChild(el);
return el;
}
// dom
function addEvent(el,event,fn){
el.addEventListener?el.addEventListener(event,fn,false):el.attachEvent("on"+event,fn);
}