title: Remove actionButton() via removeUI() function in shiny
body: <p>I'm trying to use the <code>removeUI()</code> function from the shiny package but I'm having some difficulty removing particular elements. Below is an example of this problem, slightly modified from the example in <code>help(removeUI)</code>. Specifically, the commented out line containing <code>textInput(</code> was replaced by <code>actionButton(</code> instead.</p>
  
  <pre><code>library(shiny)
  
  ui &lt;- fluidPage(
      sidebarPanel(
        actionButton("rmv", "Remove UI"),
        actionButton("txt", "This is no longer useful")
        #textInput("txt", "This is no longer useful")
      )
  )
  
  # Server logic
  server &lt;- function(input, output, session) {
    observeEvent(input$rmv, {
      removeUI(
        selector = "div:has(&gt; #txt)"
      )
    })
  }
  
  # Complete app with UI and server components
  shinyApp(ui, server)
  </code></pre>
  
  <p>While the components of <code>textInput()</code> can be removed, this method does not work for removing analogous components using <code>actionButton()</code>. I'm unsure as to why, since the logic of the jQuery selector seems the same in this case. </p>
  
  <p>I also tried changing <code>selector = "div:has(&gt; #txt)"</code> to <code>selector = "button:has(&gt; #txt)"</code>, thinking that the jQuery search would apply to the <code>button</code> elements, but again to no avail.</p>
  
  <p>EDIT: found a solution. Wrapping <code>actionButton("txt", "This is no longer useful")</code> with a <code>div()</code> puts the action button into the <code>div&lt;&gt;</code> block, so the search will work.</p>