Home > Web Front-end > JS Tutorial > body text

Several concise functions of javascript_javascript skills

WBOY
Release: 2016-05-16 18:47:28
Original
978 people have browsed it

Copy code The code is as follows:

//Date class
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();
}
// Create DOM
function createDOM(e,p){
var el=document.createElement(e);
if(!p)
p=document.body;
p.appendChild( el);
return el;
}
//Add event listening for dom
function addEvent(el,event,fn){
el.addEventListener?el.addEventListener(event,fn) ,false):el.attachEvent("on" event,fn);
}
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template