Closed ohiosveryown closed 6 years ago
@ohiosveryown heya! - usually the best way to go about this is update the class=""
attribute on an element, and then call emit('render')
. If you only update the value using classList
, you might lose the value on a re-render. E.g.
var clx = ''
app.route('/', () => {
return html`<button class=${clx} onclick=${onclick}>click</button>`
function onclick () {
clx += '.my-class'
}
})
Hope this is helpful!
Thanks for not only the help here, but the rest that you provide for everyone 🙌🏼.
Expected behavior
document.querySelector("h1").classList.add('red');
Actual behavior
??
This is a super basic question but I'm very much a js / choo novice. How can I query select a tag and add a class with choo? What would be the best way to accomplish the expected behavior code?