Last active
January 13, 2017 11:59
-
-
Save saginadir/050ac7efec643884fad7e6a33e94e274 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const wrap = (el) => ({ | |
css: (attribute, value) => { | |
el.style[attribute] = value; | |
return wrap(el); | |
}, | |
hide: () => { | |
return wrap(el).css('display', 'none'); | |
}, | |
show: () => { | |
return wrap(el).css('display', 'block'); | |
}, | |
html: (newHtml) => { | |
if(newHtml) { | |
el.innerHTML = newHtml; | |
return wrap(el); | |
} else { | |
return el.innerHTML; | |
} | |
} | |
}) | |
const $ = (el) => wrap(document.querySelector(el)) | |
const $example = $('.example'); | |
$example | |
.css('width', '100px') | |
.css('height', '100px') | |
.css('backgroundColor', 'firebrick') | |
.hide() | |
.show() | |
.html('Hello World'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment