Published
Edited
Jul 29, 2022
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
html_main; // make sure HTML is defined for Observable foo.
// selecting the :root theme
const root_theme = document.querySelector(':root');
// seleting the button which will trigger the event
const root_btn = document.querySelector('.btn-css-v');
// the event listener to change the text color upon 'click'
root_btn.addEventListener('click', () => {
// changing the color from #0b32e7 to #f44336
root_theme.style.setProperty('--demo-color-change', '#f44336');
});
}
Insert cell
Insert cell
viewof color = Inputs.color({label: "Favorite color", value: "#4682b4"})
Insert cell
html_color = html`<button>click here</button> to change the text color.`
Insert cell
changeColor = ()=>{
console.log('changeColor called')
document.querySelector(':root').style.setProperty('--demo-color-change', color)
}
Insert cell
{
html_color.querySelector('button').addEventListener('click', changeColor)
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more