Query: e1.parentElement.remove();
is not defined
debug: e1
contains a value. e1.remove()
removes a button, however, I need to remove a group of buttons.
global variable and function execution
var x = 0;
AllResponses(null, null);
primary function featuring both inquiries and predetermined user responses that can be selected
function AllResponses(e1, userPicked) {
//user response
if (e1) {
PrintUserResponse(e1, userPicked);
}
let BotQuestions = [
['Select the topic or write your question below.'],
['Before we start, our legal team requires us to inquire 😅 <br/><br/> Do you consent to LiveChat, Inc. processing your personal data?', 'Click the button below to view our Privacy Policy.'],
['Great, let me ask a few questions to connect you with the appropriate representative :)']
];
let UserOptions = [
['Contact Sales', 'Free Trail', 'Getting Started', 'Features', 'Pricing', 'Contact support'],
['Agree', 'Disagree'],
['Dave']
];
setTimeout(() => {
// Bot question
if (x != BotQuestions.length) {
var question = BotQuestions[x];
for (var y = 0; y < question.length; y++) {
let botHtml = '<p class="botText"><span>' + question[y] + '</span></p>';
$("#chatbox").append(botHtml);
}
// user option
var option = UserOptions[x];
for (var uy = 0; uy < option.length; uy++) {
let userHtml = '<button type="button" class="btn btn-small btn-primary" onclick="AllResponses(this,\'' + option[uy] + '\')">' + option[uy] + '</button><br/>';
$("#chatbox").append(userHtml);
}
x++;
}
}, 1000)
document.getElementById("chat-bar-bottom").scrollIntoView(true);
}
delete buttons and display the clicked button
function PrintUserResponse(e1, userPicked) {
if (e1) {
alert(e1.parentElement.remove());
//remove pre options
e1.parentElement.remove();
//user pre-option
let userHtml = '<p class="userText"><span>' + userPicked + '</span></p>';
$("#chatbox").append(userHtml);
document.getElementById("chat-bar-bottom").scrollIntoView(true);
}
}