title: Server Code working with Javascript in Shiny
body: <p>I want to understand how we can interact server section of code with pure JS (or Jquery). I prepared two examples - Basically I want to hide h4( ) on clicking of button by user. First example works as expected but second one does not work as h4() is in renderUI( ) in server. I know this can be solved via observeEvent or shinyJS package but I am more interested to make it work with pure JS not running JS code in server.</p>
  <p><strong>Example 1</strong></p>
  <pre><code>library(shiny)
  
  ui &lt;- fluidPage(
    fluidRow(
      h4(&quot;Testing&quot;),
      actionButton(&quot;Disable&quot;, &quot;Disable Element&quot;),
      tags$script(&quot;
      $(document).ready(function() {
        $('#Disable').click(function(){
        $('h4').css('display', 'none');
        });
  })&quot;)
    )
  )
  
  shinyApp(ui, server = function(input, output) { })
  </code></pre>
  <p><strong>Example 2</strong></p>
  <pre><code>ui &lt;- fluidPage(
    fluidRow(
      h4(&quot;Testing&quot;),
      uiOutput(&quot;myfun&quot;),
      tags$script(&quot;
      $(document).ready(function() {
        $('#Disable').click(function(){
        $('h4').css('display', 'none');
        });
  })&quot;)
    )
  )
  
  shinyApp(ui, server = function(input, output) {
    
    output$myfun &lt;- renderUI({
      
      tagList(
      actionButton(&quot;Disable&quot;, &quot;Disable Element&quot;)
      )
      
    })
    
  })
  </code></pre>