with 2 lines of code we have the jQuery find method! What does mean? Well, in most cases we dont need jQuery or other Framework...
A Pen by Bitcollage on CodePen.
<ul> | |
<li>Powerful</li> | |
<li>you</li> | |
<li>have</li> | |
<li>become</li> | |
<li>the</li> | |
<li>dark</li> | |
<li>side</li> | |
<li>I</li> | |
<li>sense</li> | |
<li>in</li> | |
<li>you</li> | |
</ul> |
with 2 lines of code we have the jQuery find method! What does mean? Well, in most cases we dont need jQuery or other Framework...
A Pen by Bitcollage on CodePen.
//******* prepare jquery like methods | |
var $ = document.querySelector.bind(document); | |
HTMLElement.prototype.find = function(selector){ | |
return this.parentNode.querySelectorAll(selector); | |
}; | |
//******* with 2 lines of code we have jQuery like find method :) | |
var res = $('ul').find('li'); | |
console.log(res); |
ul { | |
margin:0; | |
padding:0; | |
li { | |
list-style-type:none; | |
} | |
} |