आचार्य आशीष मिश्र Reply जून 26, 2024
document.addEventListener('DOMContentLoaded', () => { const addQuestionBtn = document.getElementById('add-question'); const generateHtmlBtn = document.getElementById('generate-html'); const questionsContainer = document.getElementById('questions'); const htmlCodeOutput = document.getElementById('html-code'); let questionCount = 0; // Function to add a new question input function addQuestion() { questionCount++; const questionDiv = document.createElement('div'); questionDiv.className = 'question'; questionDiv.innerHTML = `


Correct


Correct


Correct


Correct

`; questionsContainer.appendChild(questionDiv); } // Function to generate the HTML code function generateHTML() { let html = ` ${document.getElementById('quiz-title').value}

${document.getElementById('quiz-title').value}

`; for (let i = 1; i <= questionCount; i++) { html += `

Question ${i}:

${document.getElementById(`question-${i}`).value}

`; for (let j = 1; j <= 4; j++) { let answer = document.getElementById(`answer-${i}-${j}`).value; let isCorrect = document.getElementById(`correct-${i}-${j}`).checked; let answerClass = isCorrect ? 'answer correct' : 'answer incorrect'; html += `
${answer}
`; } html += `
`; } html += `
`; htmlCodeOutput.textContent = html; } // Function to copy HTML to clipboard function copyHTML() { const htmlCode = document.getElementById('html-code'); navigator.clipboard.writeText(htmlCode.textContent) .then(() => { alert("HTML code copied to clipboard!"); }) .catch(err => { console.error("Failed to copy: ", err); }); } addQuestionBtn.addEventListener('click', addQuestion); generateHtmlBtn.addEventListener('click', generateHTML); // Initial question addQuestion(); });

एक टिप्पणी भेजें

Search

चरक

स्क्रॉल करें

The Power Of Subscription Economy.

Follow us

Popular Posts

- Navigation - Archive Status