I have this code
var div = "detail"
$(`#${div}`).html("");
it shows error like this
Syntax error, unrecognized expression: #
How can I use variable as id name??
As an alternative, if you are using plain JS, you can create the variable, then use document.getElementById(variable) to find the element.
var div_id = "details";
document.getElementById(div_id).innerHTML = ""