Question: Someone please help me fix this code. Bird images /* Two color palettes */ :root { --primary-color: rgb(255, 255, 255); --secondary-color: rgb(255, 255, 255); --bg-color:
Someone please help me fix this code.
/* Two color palettes */
:root {
--primary-color: rgb(255, 255, 255);
--secondary-color: rgb(255, 255, 255);
--bg-color: rgb(255, 255, 255);
--font-color: rgb(0, 0, 0);
--heading-color: rgb(0, 0, 0);
}
[data-theme="dark"] {
--primary-color: rgb(0, 0, 0);
--secondary-color: rgb(0, 0, 0);
--bg-color: rgb(0, 0, 0);
--font-color: rgb(255, 255, 255);
--heading-color: rgb(255, 255, 255);
}
function updateHeading() {
// Get the value of the 'user_name' parameter from the query string
const urlParams = new URLSearchParams(window.location.search);
let userName = urlParams.get('user_name');
if (!userName) {
// If the query string does not contain the 'user_name' field, check local storage
userName = localStorage.getItem('user_name');
} else {
// If the query string contains the 'user_name' field, store it in local storage
localStorage.setItem('user_name', userName);
}
// Update the heading to say 'Hello,
if (userName) {
document.getElementById('heading').innerHTML = `Hello, ${userName}`;
}
}
function toggleTheme() {
// Get the current value of the 'data-theme' attribute
const currentTheme = document.documentElement.getAttribute('data-theme');
// Set the value of the 'data-theme' attribute to the opposite value
if (currentTheme === 'light') {
document.documentElement.setAttribute('data-theme', 'dark');
localStorage.setItem('theme', 'dark');
} else {
document.documentElement.setAttribute('data-theme', 'light');
localStorage.setItem('theme', 'light');
}
}
window.onload = function() {
// Check if there's a theme preference stored in local storage
const theme = localStorage.getItem('theme');
if (theme === 'dark') {
document.documentElement.setAttribute('data-theme', 'dark');
}
updateHeading();
}
Header
- Home
- Our team
- Projects
- Contact
Article heading
Pardalote by fir0002 (CC-by-NC)
Related
- Oh I do like to be beside the seaside
- Oh I do like to be beside the sea
- Although in the North of England
- It never stops raining
- Oh well...
Copyright 2050 by nobody. All rights reversed.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
