GithubHelp home page GithubHelp logo

helix's Introduction

helix

jquery-like dom manipulation. Tiny (2.1kB minified & gzipped)

Installation

$ component install matthewmueller/helix

Tests

$ make clean && make
$ xdg-open test/test.html

API

Require Helix.

var $ = require('helix');

$(selector)

Select an element.

$('.name')
$('#nav')

#text(val)

Get and set text

$('.name').text('Matt')
$('.name').text() // ["Matt"]

#html(val)

Get and set HTML

$('.name').html('<strong>Matt</strong>')
$('.name').html() // ["<strong>Matt</strong>"]

#find(selector)

Get the descendants of each element in the current set of matched elements, filtered by a selector.

$('.person').find('span')

#children(selector)

Get the direct descendants of each element in the current set of matched elements, filtered by a selector.

$('.person').children('span')

#eq(index)

Get a single element from the set of matched elements.

$('span').eq(1).html()

#addClass(cls)

Add a class

$('.name').addClass('person')

#removeClass(cls)

Remove a class

$('.name').removeClass('person')

#toggleClass(cls)

Toggle a class

$('.name').toggleClass('person')

#attr(attr, val)

Get and set attributes that are on the selected element.

<input class="user" id="user" type="text" name="user">
$('.user').attr('type', 'radio').attr('name', 'person')
$('.user').attr('type') // ["radio"]

Get and set attribute that doesn't already exist

$('.user').attr('data-author', 'matt')

#hide()

Hide all matched elements.

$('span').hide()

#show()

Show all matched elements.

$('span').show()

#toggle()

Toggle display of all matched elements.

$('span').toggle()

License

MIT

helix's People

Watchers

 avatar  avatar

helix's Issues

$(DOMElement).children() acts like find()

Because currently children() works by appending > selector to the original selector (this.selector), if Helix receives a DOMElement or another Helix instance, there's no way to infer the original selector (because there was none). And Element.querySelectorAll('> selector') is invalid. See this question.

A possible fix would be to generate the selector manually, by traversing all element's parents until the nearest element with an ID. See this question.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.