Skip to content

Instantly share code, notes, and snippets.

@SerkanSipahi
Created April 17, 2014 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SerkanSipahi/11006098 to your computer and use it in GitHub Desktop.
Save SerkanSipahi/11006098 to your computer and use it in GitHub Desktop.
A Pen by Bitcollage.
<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>

jQuery like find Method!

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.

License.

//******* 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;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment