tagAppendAttributes: Append tag attributes

Description Usage Arguments See Also Examples

View source: R/tags.R

Description

Append (tagAppendAttributes()), check existence (tagHasAttribute()), and obtain the value (tagGetAttribute()) of HTML attribute(s).

Usage

1
2
3
4
5

Arguments

tag

a tag object.

...

a collection of attributes.

.cssSelector

A character string containing a CSS selector for targeting particular (inner) tags of interest. At the moment, only a combination of type (e.g, div), class (e.g., .my-class), id (e.g., #myID), and universal (*) selectors within a given simple selector is supported. Note, if .cssSelector is used, the returned tags will have their $children fields flattened to a single list() via tagQuery().

attr

The name of an attribute.

See Also

tagAppendChildren(), tagQuery()

Examples

1
2
3
4
5
6
html <- div(a())
tagAppendAttributes(html, class = "foo")
tagAppendAttributes(html, .cssSelector = "a", class = "bar")

tagHasAttribute(div(foo = "bar"), "foo")
tagGetAttribute(div(foo = "bar"), "foo")

htmltools documentation built on Aug. 25, 2021, 5:07 p.m.