Skip to content

Instantly share code, notes, and snippets.

@k33g
Created January 6, 2012 12:51
Show Gist options
  • Save k33g/1570476 to your computer and use it in GitHub Desktop.
Save k33g/1570476 to your computer and use it in GitHub Desktop.

par exemple tu fais :

function q(selector){ return  [].slice.apply(document.querySelectorAll(selector)); }

ensuite si tu as une page web avec :

<ul><li>un</li><li>deux</li><li>trois</li></ul>

et que tu fais :

q('li')

ça va te mettre tous les

  • dans un tableau

    et du coup tu peux faire des trucs comme ça :

    q('li').forEach(function(item){ item.innerHTML = "toto"; });
    q('li')[1].backgroundColor = "red"
    

    etc. ...

    en fait c'est là dessus que s'appuie zepto

  • Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment