0% found this document useful (0 votes)
8 views1 page

1

Uploaded by

Pranjal kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

1

Uploaded by

Pranjal kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

<!

DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Random Content</title>
<style>

</style>
</head>
<body>
<div id="random-content">
<>
</div>

<script>

const contentPool = [
{ title: "Article 1", description: "Description for Article 1",
imageUrl: "image1.jpg" },
{ title: "Article 2", description: "Description for Article 2",
imageUrl: "image2.jpg" },
{ title: "Article 3", description: "Description for Article 3",
imageUrl: "image3.jpg" }
// Add more content items as needed
];

// Function to select random content


function selectRandomContent() {
return contentPool[Math.floor(Math.random() * contentPool.length)];
}

// Function to display content on the page


function displayContent(content) {
const contentDiv = document.getElementById('random-content');
contentDiv.innerHTML = `
<h2>${content.title}</h2>
<p>${content.description}</p>
<img src="${content.imageUrl}" alt="${content.title}">
`;
}

// Display random content when the page loads


window.onload = function() {
const randomContent = selectRandomContent();
displayContent(randomContent);
};
</script>
</body>
</html>

You might also like