Show:

Element Class

Q extended methods for DOM Elements

Methods

addClass

(
  • className
)
Element chainable

Restore ability to select text in an element

Parameters:

Returns:

Element:

returns this, for chaining

adjustScrolling

(
  • element
)

Call this to make sure scrolling is adjusted properly after contents have changed. Some browsers, such as Safari on iOS, don't act properly unless this is called.

Parameters:

computedStyle

(
  • [name]
)
Object | String

Returns a snapshot of the computed style of an element.

Parameters:

  • [name] String optional

    If provided, the value of a property is returned instead of the whole style object.

Returns:

contains

(
  • child
)
Boolean

Check whether this element is the given element or contains it

Parameters:

Returns:

copyComputedStyle

(
  • src
)
Element

Copies the computed style from another Element, and assigns it to this Element.

Parameters:

Returns:

Element:

returns this, for chaining

hasClass

(
  • className
)
Boolean

Check whether this element has a given CSS class

Parameters:

Returns:

innerText

() String

Get the text content of an element (as opposed to its inner HTML)

Returns:

isBefore

(
  • element
  • context
)
Boolean

Check whether this Element comes before another one, in a certain context

Parameters:

  • element Element
  • context Element

    optional containing element, defaults ot the document element

Returns:

isOverflowed

() Boolean

Returns whether the element's content has overflowed the element's bounds. Does not work in IE8 and below for elements with {text-overflow: ellipsis}.

Returns:

isVisible

() Boolean

Returns whether the element's is visible

Returns:

preventSelections

(
  • deep
  • callouts
)

Prevent ability to select text in an element

Parameters:

  • deep Boolean

    whether to prevent it also on child elements

  • callouts Boolean

    whether to also cancel the callouts in webkit

Q

(
  • toolName
)
Q.Tool | Null

Call this on an element to access tools attached to it. The tools are like "view models". this method is overridden by the tool constructor on specific elements

Parameters:

Returns:

Q.Tool | Null:

remainingWidth

(
  • subpixelAccuracy
)
Number | Null

Gets the width remaining after subtracting all the siblings (except text nodes) on the same line.

Parameters:

Returns:

Number | Null:

Returns the remaining width, or null if element has no parent

removeClass

(
  • className
)
Element chainable

Remove a CSS class from the element

Parameters:

Returns:

Element:

returns this, for chaining

restoreSelections

(
  • deep
)
Boolean

Restore ability to select text in an element

Parameters:

  • deep Boolean

    whether to restore it also on child elements

Returns:

scrollingParent

(
  • [skipIfNotOverflowed=false]
  • [direction="all"]
)

Returns the first element in the chain of parent elements which supports scrolling

Parameters:

  • [skipIfNotOverflowed=false] Boolean optional

    If element is not overflowed, continue search

  • [direction="all"] String optional

    Can also be "vertical" or "horizontal"

setClass

(
  • className
  • condition
)
Element chainable

Adds or removes an element according to whether a condition is truthy

Parameters:

Returns:

Element:

returns this, for chaining

swap

(
  • element
)

Switch places with another element

Parameters: