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

199
Views
¿Cómo se muestra una imagen con una fuente adjunta a un objeto? El objeto (pregunta) se selecciona al azar y las imágenes deben cambiar con ellos

Tengo una serie de objetos que son preguntas. Esto es para un cuestionario de preguntas aleatorias. Básicamente, cuando se selecciona una pregunta al azar, pensé que todos los atributos irían con ella (si se "llamaba" correctamente). No estoy seguro de cómo mostrar la imagen del objeto cuando aparece el texto de la pregunta (q).

 const questionBank = [ { q: "This is question 1's text", options:['1','2','3','4', '5'], answer:4, imgURL: 'http://drive.google.com/uc?export=view&id=googleDriveId', }, { q: "question 2 will go here", options:['7','6','4'], answer:0, imgURL: 'http://drive.google.com/uc?export=view&id=differentDriveId', } function getNewQuestion(){ const question = document.querySelector(".question"); //set question text question.innerHTML = currentQuestion.q; //add image to question //document.querySelector('.question').appendChild(img); (attempted, did not work) //var img = new Image(); (attempted, did not work) //img = document.createElement("img"); (attempted, did not work) //img.src = document.querySelector('.imgUrl'); (attempted, did not work)

Creo que ese es todo el código relevante.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Estaba en el camino correcto al crear un nuevo elemento img, si echa un vistazo a esta publicación, necesita crear un nuevo elemento de imagen.

en su última línea, en su lugar, configure image.src = currentQuestion.imgURL como desea que la propiedad imgURL de las preguntas actuales, luego puede appendChild() su nuevo elemento de imagen.

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!