// selecting by id
hx.select('#some-id')
// selecting one element by class
hx.select('.some-class')
// selecting all elements by class
hx.selectAll('.some-class')
// selecting all elements by type
hx.selectAll('div')
hx.selectAll('button')
hx.select('input')
// chaining selects to limit selections to a certain part of the dom
hx.select('#some-id').selectAll('.some-class')
// setting a style property for a selection
hx.selectAll('.some-class').style('background', 'red')
// getting a style property for a selection
hx.selectAll('.some-class').style('background')
// get the height of an element
hx.select('#some-id').height()
html
method for selections has been removed to prevent XSS attacks. selection.prop('innerHtml', value)
<div>
element for example.
.api('name')) select(thisNode).api('name')
.api('name')) <div>
element for example. // will set the class attribute value to 'myclass' for the
// single element in the selection this will return the current
// selection for chaining
hx.select('#some-id').attr('placeholder', 'Enter Text...')
// will set the class attribute value to 'myclass' for all the
// elements in the selection this will return the current selection
// for chaining
hx.selectAll('.some-class').attr('placeholder', 'Enter Text...')
// will return the class attribute for the selected element
hx.select('#some-id').attr('class')
// will return an array of class attributes for all the selected elements
hx.selectAll('.some-class').attr('class')
selection.attr('class', value)
hx.select('#button').off('click')
hx.select('#button').off('click', 'my-namespace')
hx.select('#button').off('click', handler)
hx.select('#button').off('click', 'my-namespace', handler)
function handler (event) {
// do something
}
hx.select('#button').on('click', handler)
hx.select('#button').on('click', 'my-namespace', handler)
<div>
element for example. // will set the className property value to 'myclass'
// for the single element in the selection this will
// return the current selection for chaining
hx.select('#some-id').prop('className', 'myclass')
// will set the className property value to 'myclass'
// for all the elements in the selection this will
// return the current selection for chaining
hx.selectAll('.some-class').prop('className', 'myclass')
// will return the className attribute for the selected element
hx.select('#some-id').prop('className')
// will return an array of className attributes for all the selected elements
hx.selectAll('.some-class').prop('className')
hx.select('.some-container')
.replace(hx.div('my-content'))
hx.select('.some-container')
.replace([
hx.div('my-content-1'),
hx.div('my-content-2')
])
hx.select('.some-container')
will be removed from the DOM. hx.select('.some-container').insertAfter(hx.div('my-content'))
hx.select('.some-container').remove()
hx.select('body')
.set(hx.div('my-content'))
hx.select('body')
.set([
hx.div('my-content-1'),
hx.div('my-content-2')
])
hx.select('body')
.clear()
.add(hx.div('my-content'))
// will set the class style property value to 'myclass' for
// the single element in the selection this will return the
// current selection for chaining
hx.select('#some-id').style('background', 'red')
// will set the class style property value to 'myclass' for
// all the elements in the selection this will return the current
// selection for chaining
hx.selectAll('.some-class').style('background', 'red')
// will return the class style property for the selected element
hx.select('#some-id').style('background')
// will return an array of class style propertys for all the selected elements
hx.selectAll('.some-class').style('background')
selection.prop('textContent', value)