html_attr | R Documentation |
html_attr()
gets a single attribute; html_attrs()
gets all attributes.
html_attr(x, name, default = NA_character_)
html_attrs(x)
x |
A document (from |
name |
Name of attribute to retrieve. |
default |
A string used as a default value when the attribute does not exist in every element. |
A character vector (for html_attr()
) or list (html_attrs()
)
the same length as x
.
html <- minimal_html('<ul>
<li><a href="https://a.com" class="important">a</a></li>
<li class="active"><a href="https://c.com">b</a></li>
<li><a href="https://c.com">b</a></li>
</ul>')
html %>% html_elements("a") %>% html_attrs()
html %>% html_elements("a") %>% html_attr("href")
html %>% html_elements("li") %>% html_attr("class")
html %>% html_elements("li") %>% html_attr("class", default = "inactive")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.