Options
All
  • Public
  • Public/Protected
  • All
Menu

Class JQ

The main jQuery class

Hierarchy

  • JQ

Index

Constructors

constructor

  • new JQ(selectorOrElement: string | HTMLElement): JQ
  • Create $elItems by the selector

    Parameters

    • selectorOrElement: string | HTMLElement

    Returns JQ

Properties

Private $elItems

$elItems: HTMLElement[] = []

An array of HTMLElements for next use by methods in the chain (for chain of responsibility (pattern))

Accessors

items

  • get items(): HTMLElement[]
  • Get the array of $elItems. it's needed to get an array element by index

    example

    $("p").items[0]

    Returns HTMLElement[]

length

  • get length(): number
  • Get the count of $elItems

    Returns number

Methods

addClass

  • addClass(classes: string): JQ
  • Add classes for $elItems

    Parameters

    • classes: string

    Returns JQ

append

  • append(position: InsertPosition, element: string | HTMLElement | JQ | HTMLElement[]): JQ
  • Parameters

    • position: InsertPosition
    • element: string | HTMLElement | JQ | HTMLElement[]

    Returns JQ

attr

  • attr(attrName: string, dataValueName?: string | number): string | JQ
  • Get/set attribute

    description

    If there are more than one $elItems, then return get for first element

    Parameters

    • attrName: string
    • Optional dataValueName: string | number

    Returns string | JQ

click

  • click(): JQ

closest

  • closest(selector: string): JQ
  • Return closest elements for first el of $elItems

    Parameters

    • selector: string

    Returns JQ

css

  • css(cssPropNames: string[] | {}): object | JQ
  • Parameters

    • cssPropNames: string[] | {}

      if cssPropNames is array, then return {propName: prop:Value} or {"display": "none"} for first element if cssPropNames is object, then set css prop values

    Returns object | JQ

data

  • data(dataName: string, dataValueName?: string): string | JQ
  • Get/set data attribute.

    description

    If there are more than one $elItems, then return get for first element

    Parameters

    • dataName: string
    • Optional dataValueName: string

    Returns string | JQ

each

  • each(callBackFunction: (el: HTMLElement, index: number) => void): JQ
  • Set callback function for each $elItems

    Parameters

    • callBackFunction: (el: HTMLElement, index: number) => void
        • (el: HTMLElement, index: number): void
        • Parameters

          • el: HTMLElement
          • index: number

          Returns void

    Returns JQ

find

  • find(selector: string): JQ
  • Find child selector for first element of $elItems

    Parameters

    • selector: string

    Returns JQ

Private getFirstEl

  • getFirstEl(tagName?: string): HTMLElement
  • get first element or first element with tag of $elItems

    Parameters

    • Optional tagName: string

    Returns HTMLElement

Private getSiblings

  • getSiblings(): HTMLElement[]

Private getSplitClassess

  • getSplitClassess(classes: string): string[]
  • Split the classes string by reapeting spaces

    Parameters

    • classes: string

    Returns string[]

hasClass

  • hasClass(classes: string): boolean
  • If each of the $elItems has class(es) then return true else return false

    Parameters

    • classes: string

    Returns boolean

Private helpForEach

  • helpForEach(callbackFunction: (value: HTMLElement, index: number, array: Element[]) => void, thisArg?: any): void
  • Parameters

    • callbackFunction: (value: HTMLElement, index: number, array: Element[]) => void
        • (value: HTMLElement, index: number, array: Element[]): void
        • Parameters

          • value: HTMLElement
          • index: number
          • array: Element[]

          Returns void

    • Optional thisArg: any

    Returns void

hide

  • hide(duration?: number): JQ

Private hideEl

  • hideEl(el: HTMLElement, duration: number): void
  • help function for one element in hide()

    Parameters

    • el: HTMLElement
    • duration: number

    Returns void

html

  • html(htmlString?: string): string | JQ
  • set for $elItems or get innerHTML for first element of $elItems

    Parameters

    • Optional htmlString: string

    Returns string | JQ

on

  • on(currentEvent: string, callback: EventListener): JQ
  • Set eventHandler for each $elItems

    Parameters

    • currentEvent: string

      native js event name

    • callback: EventListener

    Returns JQ

Private operateAttribute

  • operateAttribute(eventLabel: string, attr: string, attrValue?: string | number, isData?: boolean): string | JQ
  • The main function for attribute actions

    Parameters

    • eventLabel: string
    • attr: string
    • Optional attrValue: string | number
    • isData: boolean = false

    Returns string | JQ

Private operateClassEventLabel

  • operateClassEventLabel(eventLabel: string, classes: string): JQ
  • A main method for working with HTMLElement classes

    Parameters

    • eventLabel: string
    • classes: string

    Returns JQ

Private operateHideOrShow

  • operateHideOrShow(cssValue: string): void
  • Parameters

    • cssValue: string

    Returns void

removeAttr

  • removeAttr(attrName: string, dataValueName?: string): string | JQ
  • Remove attribute

    Parameters

    • attrName: string
    • Optional dataValueName: string

    Returns string | JQ

removeClass

  • removeClass(classes: string): JQ
  • Remove classes for $elItems

    Parameters

    • classes: string

    Returns JQ

removeData

  • removeData(dataName: string, dataValueName?: string): string | JQ
  • Remove data attribute

    Parameters

    • dataName: string
    • Optional dataValueName: string

    Returns string | JQ

Private removePx

  • removePx(value: string): number
  • Parameters

    • value: string

    Returns number

Private setPx

  • setPx(value: number): string
  • Parameters

    • value: number

    Returns string

show

  • show(duration?: number, display?: string): JQ
  • Parameters

    • Optional duration: number
    • display: string = 'block'

    Returns JQ

Private showEl

  • showEl(el: HTMLElement, duration: number): void
  • help function for one element in show()

    Parameters

    • el: HTMLElement
    • duration: number

    Returns void

siblings

  • siblings(selector?: string): JQ
  • Return sibling elements for first el of $elItems

    Parameters

    • Optional selector: string

    Returns JQ

slideToggle

  • slideToggle(duration?: number): JQ

text

  • text(parText?: string): string | JQ
  • set/ get text for first element

    Parameters

    • Optional parText: string

    Returns string | JQ

toggleClass

  • toggleClass(classes: string): JQ
  • Toggle classes for $elItems

    Parameters

    • classes: string

    Returns JQ

val

  • val(value?: string): string | JQ
  • return a input value of first input in list

    Parameters

    • Optional value: string

      a input value for set

    Returns string | JQ

Generated using TypeDoc