new Faquery()
Approximates a subset of jQuery functionality.
This class exists to support jQuery-like methods within the existing web components.
Note: New web components should be written using native accessors instead of the undocumented methods of this class. The methods are designed for backward compatibility with older code that used jQuery; they are not intended for direct API use.
- Since:
-
8.1.0
Methods
-
addClass(classes)
-
Add css classes.
Parameters:
Name Type Description classes
string | Array.<string> List of classes, either space delimited or an array.
Returns:
Returns itself.
- Type
- Faquery
-
append(content, invalid)
-
Append DOM elements.
Parameters:
Name Type Description content
string | Array.<string> | Faquery | HTMLElement | Array.<HTMLElement> DOM to append. If a string, will set inner content.
invalid
undefined Not used. Faquery.append does not accept a second argument like jQuery does.
Returns:
Returns itself
- Type
- Faquery
-
attr(nameOrObject [, value])
-
Set/Get HTML attributes. If first parameter is an object, this method will set the attributes in the keys to their respective values. If first parameter is a string, and second parameter is not undefined, attribute specified in first parameter will be set to value in second. If first parameter is a string, and second parameter is undefined, function will return existing attribute value.
Parameters:
Name Type Argument Description nameOrObject
string | Object Attribute name or an object with name-value pairs.
value
string <optional>
If supplied, will set the attribute whose name is specified in
nameOrObject
(if a string).Returns:
Returns itself if setting an attribute, or the attribute's value if getting an attribute.
- Type
- Faquery | string
-
children(selector)
-
Get child elements.
Parameters:
Name Type Description selector
string Selector for children to get.
Returns:
Returns children.
- Type
- Faquery
-
css(nameOrObject [, value])
-
Set/Get element css styles. If first parameter is an object, this method will set the styles in the keys to their respective values. If first parameter is a string, and second parameter is not undefined, style specified in first parameter will be set to value in second. If first parameter is a string, and second parameter is undefined, function will return existing style value.
Parameters:
Name Type Argument Description nameOrObject
string | Object Style property name or an object with name-value pairs.
value
string <optional>
If supplied, will set the property whose name is specified in
nameOrObject
(if a string).Returns:
Returns itself if setting a property, or the property's value if getting a property.
- Type
- Faquery | string
-
each(func)
-
Call a function on each element.
Parameters:
Name Type Description func
function Function to call. Signature is: first parameter is the index, second is the element.
this
is available as the element being iterated.Returns:
Returns itself.
- Type
- Faquery
-
empty()
-
Remove content from element(s).
Returns:
Returns itself.
- Type
- Faquery
-
find(selector)
-
Find descendant elements.
Parameters:
Name Type Description selector
string Selector for descendants to get.
Returns:
Returns descendants.
- Type
- Faquery
-
hasClass(className)
-
Test if any element contains a class.
Parameters:
Name Type Description className
string Name of class to test.
Returns:
True if at least one element has the class.
- Type
- boolean
-
hide()
-
Hide DOM element(s). Display style is set to "none".
Returns:
Returns itself.
- Type
- Faquery
-
html( [value])
-
Set/Get inner HTML. If
value
not supplied, will return innerHTML.Parameters:
Name Type Argument Description value
string <optional>
If setting, value to set innerHTML to.
Returns:
Returns itself if setting, or innerHTML if getting.
- Type
- Faquery | string
-
nextAll(selector)
-
Find subsequent sibling elements.
Parameters:
Name Type Description selector
string Selector for siblings to get.
Returns:
Returns subsequent siblings.
- Type
- Faquery
-
not(selector)
-
Get nonmatching elements.
Parameters:
Name Type Description selector
string Selector for elements to omit.
Returns:
Returns nonmatching elements.
- Type
- Faquery
-
parent(selector)
-
Get parent elements.
Parameters:
Name Type Description selector
string Selector for parent to get.
Returns:
Returns matching parents.
- Type
- Faquery
-
parents(selector)
-
Get ancestors.
Parameters:
Name Type Description selector
string Selector for ancestors to get.
Returns:
Returns matching ancestors.
- Type
- Faquery
-
prop(nameOrObject [, value])
-
Set/Get element properties. If first parameter is an object, this method will set the properties in the keys to their respective values. If first parameter is a string, and second parameter is not undefined, property specified in first parameter will be set to value in second. If first parameter is a string, and second parameter is undefined, function will return existing property value.
Parameters:
Name Type Argument Description nameOrObject
string | Object Property name or an object with name-value pairs.
value
string <optional>
If supplied, will set the property whose name is specified in
nameOrObject
(if a string).Returns:
Returns itself if setting a property, or the property's value if getting a property.
- Type
- Faquery | string
-
remove(selector)
-
Remove elements from DOM that match a selector.
Parameters:
Name Type Description selector
string Query selector to match.
Returns:
Returns itself.
- Type
- Faquery
-
removeAttr(attributes)
-
Remove HTML attributes.
Parameters:
Name Type Description attributes
string | Array.<string> Attribute name(s) to remove.
Returns:
Returns itself.
- Type
- Faquery
-
removeClass(classes)
-
Remove css classes.
Parameters:
Name Type Description classes
string | Array.<string> List of classes, either space delimited or an array.
Returns:
Returns itself.
- Type
- Faquery
-
show()
-
Show DOM element(s). Display style is set to "block".
Returns:
Returns itself.
- Type
- Faquery
-
text( [value])
-
Set/Get inner text. If
value
not supplied, will return innerText.Parameters:
Name Type Argument Description value
string <optional>
If setting, value to set innerText to.
Returns:
Returns itself if setting, or innerText if getting.
- Type
- Faquery | string
-
val( [value])
-
Set/Get value property. If
value
not supplied, will return existingvalue
property value.Parameters:
Name Type Argument Description value
string <optional>
If setting, value to set
value
property to.Returns:
Returns itself if setting, or value of
value
property if getting.- Type
- Faquery | string