Which of the following code snippets will toggle a div element's background color? <button id="toggle">Toggle</button> <div id="terd">Change Background Color.</div>
Correct Answer: <script> var button = document.getElementById('toggle'); button.onclick = function() { terd.style.backgroundColor = terd.style.backgroundColor == 'blue' ? 'red' : 'blue'; }; </script>
Explanation:
Note: This Question is unanswered, help us to find answer for this one
More JavaScript MCQ Questions