Class: HtmlTag

HtmlTag


new HtmlTag(name, publicId, options)

Represents an HTML (DOM) tag

Parameters:
Name Type Argument Description
name string

the name of the tag

publicId string <optional>
options Object
Example
tag = new HtmlTag( 'div', { 'width': 10})

Methods


.new(name, publicId, options)

Convenience constructor Creates a new instance of an HTML (DOM) tag

Parameters:
Name Type Argument Description
name string

the name of the tag

publicId string <optional>
options Object
Returns: HtmlTag
Type
HtmlTag
Example
tag = HtmlTag.new( 'div', { 'width': 10})

#attributes()

Get the attributes of the tag.

Returns: Object

attributes

Type
Object

#getAttr(name)

Get the value of the tag attribute name

Parameters:
Name Type Description
name string

the name of the attribute

Returns: *
Type
*

#getOption(name)

Get the value of option name

Parameters:
Name Type Description
name string

the name of the option

Returns: *

Returns the value of the option

Type
*

#getOptions()

Get all options related to this tag.

Returns: Object

the options

Type
Object

#removeAttr(name)

Remove the tag attributed named name

Parameters:
Name Type Description
name string

the name of the attribute

Returns: *
Type
*

#setAttr(name, value)

Set a tag attribute named name to value

Parameters:
Name Type Description
name string

the name of the attribute

value string

the value of the attribute


#toAttribute(key, value)

Represent the given key and value as an HTML attribute.

Parameters:
Name Type Description
key string

attribute name

value * | boolean

the value of the attribute. If the value is boolean true, return the key only.

Returns: string

the attribute

Type
string

#toDOM()

Creates a DOM object representing the tag.

Returns: Element
Type
Element

#toHtml()

Generates an HTML representation of the tag.

Returns: string

Returns HTML in string format

Type
string