I am attempting to substitute a matching class from a JavaScript variable before dynamically appending generated content. The goal is to identify one ID out of all the IDs in this variable and replace the 'hideeee' class with it. While I know this can be achieved easily using:
document.getElementById("testid").classList.remove('hideeee');
This method requires the specific ID to be available in the DOM, however, we are aiming to insert this data and display only the row that matches the clicked ID.
When these buttons are clicked, they send the ID of the clicked button which we capture using event.target.id
. In the content variable, an extra 'y' has been appended to differentiate these IDs from the original ones. By default, the .hideeee
class has a style of display:none
, so we want to remove this class when the ID matches the showthisclass
variable before appending it in the last line.
function showpdfaq1() {
console.log(event.target.id);
var showthisclass = event.target.id+'y';
let heading = `...`; // Heading content goes here
let content = `...`; // Content section goes here
var finalcontkke = document.getElementById(showthisclass).classList.remove(hideeee);
document.getElementById("appnewchat5").innerHTML = gethtml(heading, content);
}