An object to manage html elements of a WebECRF form.
More...
#include <ScriptableWebElement.h>
|
void | appendInsideHTML (string html) |
| Appends the given html inside the element.
|
|
void | appendOutsideHTML (string html) |
| Appends the given html outside the element.
|
|
void | setAttribute (string key, string value) |
| Sets an attribute value.
|
|
void | setProperty (string propertyName, string value) |
| Sets a property value.
|
|
void | addClass (string className) |
| Adds a class to an element.
|
|
void | setPlainText (string text) |
| Set and element with the given plain text.
|
|
bool | hasAttribute (string key) |
| Check if an element has the given attribute key.
|
|
string | getAttribute (string key, string defaultVal=string()) |
| Gets a given attribute value.
|
|
string | toString () |
| Gets the element as a string.
|
|
string | tagName () |
| Gets the tag name of the element.
|
|
Array< string > | classes () |
| Gets the list of classes contained in the element.
|
|
string | plainText () |
| Gets the element as plain text.
|
|
void | evalJavaScript (string js) |
| Evaluate JavaScript on the element.
|
|
An object to manage html elements of a WebECRF form.
It provides functions to access the element's HTML directly or access the attributes of the element.
See also WebECRF::getElement() or WebECRF::getAllElement() to obtain this object.
◆ addClass()
void addClass |
( |
string |
className | ) |
|
Adds a class to an element.
- Parameters
-
className | The class name to add |
◆ appendInsideHTML()
void appendInsideHTML |
( |
string |
html | ) |
|
Appends the given html inside the element.
- Parameters
-
◆ appendOutsideHTML()
void appendOutsideHTML |
( |
string |
html | ) |
|
Appends the given html outside the element.
- Parameters
-
◆ classes()
Array< string > classes |
( |
| ) |
|
Gets the list of classes contained in the element.
- Returns
- An array of string with the class names
◆ getAttribute()
string getAttribute |
( |
string |
key, |
|
|
string |
defaultVal = string() |
|
) |
| |
Gets a given attribute value.
- Parameters
-
key | The given attribute key |
defaultVal | The default attribute value if it doesn't exist |
- Returns
- The attribute value
◆ hasAttribute()
bool hasAttribute |
( |
string |
key | ) |
|
Check if an element has the given attribute key.
- Parameters
-
key | The given attribute key |
- Returns
- True if the attribute exists, false otherwise
◆ plainText()
Gets the element as plain text.
- Returns
- A string containing the plain text
◆ setAttribute()
void setAttribute |
( |
string |
key, |
|
|
string |
value |
|
) |
| |
Sets an attribute value.
- Parameters
-
key | The attribute key |
value | The new attribute value |
- Returns
- The attribute value
◆ setPlainText()
void setPlainText |
( |
string |
text | ) |
|
Set and element with the given plain text.
- Parameters
-
◆ setProperty()
void setProperty |
( |
string |
propertyName, |
|
|
string |
value |
|
) |
| |
Sets a property value.
- Parameters
-
propertyName | The property name |
value | The new property value |
- Returns
- The property value
- Note
- Property and attribute can are not map 1:1 and can have different values. For a persistent "value", this method should be used.
◆ tagName()
Gets the tag name of the element.
- Returns
- The tag name
◆ toString()
Gets the element as a string.
- Returns
- The element as a string