In your above code you are overwriting your first variable jsCode with the second one.
Just put both js functions in the same string.
Furthermore all shiny inputs need their unique id. You used "col" twice.
Please check the following:
library(shiny)
library(shinyjs)
jsCode <- '
shinyjs.backgroundCol = function(params) {
var defaultParams = {
id : null,
col : "red"
};
params = shinyjs.getParams(params, defaultParams);
var el = $("#" + params.id);
el.css("background-color", params.col);};
shinyjs.pageCol = function(params){$("body").css("background", params);};'
shinyApp(
ui = fluidPage(
useShinyjs(),
extendShinyjs(text = jsCode, functions = c("backgroundCol", "pageCol")),
selectInput("pageCol", "Page colour",
c("green", "yellow", "red", "blue", "white")),
hr(),
selectInput("selector", "Element", c("sport", "name", "button")),
selectInput("backgroundColSelect", "Background colour:",
c("yellow", "white", "red", "blue", "purple")),
p(id = "name", "My name is Dean"),
p(id = "sport", "I like soccer"),
actionButton("button", "Go")
),
server = function(input, output) {
observeEvent(input$button, {
js$backgroundCol(input$selector, input$backgroundColSelect)
js$pageCol(input$pageCol)
})
}
)