Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

179
Views
parentElement.remove() no está definido cuando se trabaja con una matriz

Problema: e1.parentElement.remove(); es indefinido

depuración: e1 tiene un valor. e1.remove() elimina un botón, pero necesito eliminar un grupo de botones.

variable global y función de ejecución

 var x = 0; AllResponses(null, null);

función principal que tiene preguntas de bot y respuestas de usuario prefabricadas, donde el usuario puede hacer clic en

 function AllResponses(e1, userPicked) { //user responsed if (e1) { PrintUserResponse(e1, userPicked); } let BotQuestions = [ ['Select the topic or write your question below.'], ['Before we start, our legal made us ask 😅 <br/><br/> Do you agree to have your personal data processed by LiveChat, Inc.?', 'Click the button below to see our Privacy Policy.'], ['Great, let me just ask a couple of questions so I can find the right rep for you :)'] ]; let UserOptions = [ ['Contact Sales', 'Free Trail', 'Getting Started', 'Features', 'Pricing', 'Contact suppot'], ['Agree', 'Disgree'], ['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); }

eliminar botones y mostrar en qué botón se hizo clic

 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); } }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

lo tengo, parece que tuve que agrupar todos los botones en un div. que funciona bien.

 var option = UserOptions[x]; let userHtml = '<div style="padding: 15px !important;">'; for (var uy = 0; uy < option.length; uy++) { userHtml += '<button style="margin-bottom: 10px !important" type="button" class="btn btn-lg btn-default" onclick="AllResponses(this,\'' + option[uy] + '\')">' + option[uy] + '</button>&nbsp&nbsp&nbsp'; } userHtml += "</div>"; $("#chatbox").append(userHtml);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!