Gothic Poems to Love & Liberty
A hauntingly beautiful collection of poetry that explores love, freedom, and the shadows of the soul.
📖 Paperback: $7.99
Buy on Amazon
A hauntingly beautiful collection of poetry that explores love, freedom, and the shadows of the soul.
<link href="https://cdn.jsdelivr.net/gh/Mushahid7734/ClasswithMason.com/classwithmason1.1.min.css" rel="stylesheet" crossorigin="anonymous"/>
Step 2: Paste following html code where you want this widget to appear. Of course the content of your selection etc.
<div class="riddle-card">
<h2>Riddle of the Day</h2>
<div id="riddle-of-the-day">
<div class="riddle">Loading...</div>
</div>
<button id="show-answer-btn" style="display: none;">Show Answer</button>
<div id="answer" class="answer" style="display: none;"></div>
</div>
Step 3: Place below given javascript just below the html code
<script>
document.addEventListener('DOMContentLoaded', function() {
const riddleElement = document.getElementById('riddle-of-the-day');
const showAnswerBtn = document.getElementById('show-answer-btn');
const answerElement = document.getElementById('answer');
fetch('https://riddles-api.vercel.app/random')
.then(response => response.json())
.then(data => {
riddleElement.innerHTML = `<div class="riddle">${data.riddle}</div>`;
answerElement.textContent = data.answer;
showAnswerBtn.style.display = 'inline-block';
showAnswerBtn.addEventListener('click', () => {
answerElement.style.display = 'block';
showAnswerBtn.style.display = 'none';
});
})
.catch(error => {
console.error('Error:', error);
riddleElement.innerHTML = '<div class="riddle">An error occurred while fetching the riddle.</div>';
});
});
</script>