Description Usage Arguments Note See Also Examples
Change the text or HTML inside an element. The given HTML can be any R expression, and it can either be appended to the currentcontents of the element or overwrite it (default).
| 1 | 
| id | The id of the element/Shiny tag | 
| html | The HTML/text to place inside the element. Can be either simple plain text or valid HTML code. | 
| add | If  | 
| selector | JQuery selector of the elements to target. Ignored if the  | 
shinyjs must be initialized with a call to useShinyjs()
in the app's ui.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | if (interactive()) {
  library(shiny)
  shinyApp(
    ui = fluidPage(
      useShinyjs(),  # Set up shinyjs
      actionButton("btn", "Click me"),
      p(id = "element", "Watch what happens to me")
    ),
    server = function(input, output) {
      observeEvent(input$btn, {
        # Change the following line for more examples
        html("element", paste0("The date is ", date()))
      })
    }
  )
}
## Not run: 
  # The shinyjs function call in the above app can be replaced by
  # any of the following examples to produce similar Shiny apps
  html("element", "Hello!")
  html("element", " Hello!", TRUE)
  html("element", "<strong>bold</strong> that was achieved with HTML")
  local({val <- "some text"; html("element", val)})
  html(id = "element", add = TRUE, html = input$btn)
## End(Not run)
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.