• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

198
Views
Cómo hacer que mi código se muestre mediante programación en mi archivo html

Estoy tratando de obtener mi código para mostrar los objetos en la página web, así como la imagen asociada con él y cada objeto de automóvil también debe incluir un método showMore (). Este método debería mostrar un diálogo que muestre todos los detalles sobre el objeto de automóvil específico.

aquí está el código:

 const show = document.getElementById('show'); function carDescription(make, model, colour, image, registrationnumber, price ) { this.make = make; this.model = model; this.colour = colour; this.image = image; this.registrationnumber = registrationnumber; this.price = price; }; let car = { make:"Porsche", model:"GT3", colour:"Black", image:"src=https://pictures.topspeed.com/IMG/crop_webp/201210/1200hp-porsche-911-g_1920x1080.webp" , registrationnumber:"LMO 909 GP", price: 1000000}; let car2 = newcarDescription("Ford", "Fiesta", "Red","https://i.ytimg.com/vi/abVgt23rmrA/hqdefault.jpg", "MNO 010 EC", 100000); let car3 = newcarDescription("Opel", "Corsa", "White","https://img.gumtree.co.za/api/v1/za-pt10-ads/images/a1/a15f67b3-c11c-40b6-85ad-2987e84e956b?rule=s-I3.auto", "KLJ 899 GP", 55000); let car4 = newcarDescription("Mazda", "CX-5", "Black","https://i.pinimg.com/originals/54/d2/0b/54d20b0bee90aaef22a68b5628441832.jpg" ,"TYH 890 GP", 210000); let car5 = newcarDescription("Toyota", "Hilux", "Gold","https://imganuncios.mitula.net/medium/toyota_hilux_toyota_hilux_1050104654262066309.jpg" ,"HSG 573 EC", 250000); function print() { let myString = JSON.stringify(car); document.getElementById("show").innerHTML = `<h3>${car}</h3>` }
 <!DOCTYPE html> <html onload="print()" lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Cars</title> </head> <body > <div id="show"> </div> <script src="cars.js"></script> </body> </html>
about 3 years ago · Juan Pablo Isaza
1 answers
Answer question

0

La función de impresión debe crear una etiqueta para cada elemento del objeto del automóvil.

 let car = { make:"Porsche", model:"GT3", colour:"Black", image:"src=https://pictures.topspeed.com/IMG/crop_webp/201210/1200hp-porsche-911-g_1920x1080.webp" , registrationnumber:"LMO 909 GP", price: 1000000}; (function print() { let h3 = document.createElement("h3"); h3.innerHTML= car.model; document.getElementById("show").appendChild(h3); })();
about 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error