Thanks for the answer. However, I tried below that I thought a simple approach and it is working
WHat you say ?
library(shiny)
runApp(
list(ui = fluidPage(
tags$p(id = 'g', class = 'newClass', 'This is a paragraph'),tags$p(id = "demo"),
tags$script('Shiny.addCustomMessageHandler("testmessage",
function(message)
{
var tit = document.getElementById("g")
tit.onclick = function (){document.getElementById("demo").innerHTML = message}
}
);')
)
, server = function(input, output, session){
asd <- Sys.Date()
observe({session$sendCustomMessage(type = 'testmessage',message = asd)})
})
)