Hey all, how can I add style to an element after its creation?
I have some a place in my project that creates (h/div {:style "min-width: 40px; min-height:80px;background-color:#ebffca;"} "a"),
and then in another place I want to enrich it, like (assoc elem :style "width:100%").
How can I do it?
for the jquery impl., you can use a special :css attribute like such: https://github.com/hoplon/demos/blob/326cdb6299ebe6e1d6ce504d61a88e84e70d968a/demos-homepage/src/demo/homepage.cljs#L21C1-L22
the attribute value can be a cell that you can modify
do i need to wrap my element in a div? I prefer appending \ overriding the current style of the element without adding a new one. Something like that:
(def a (h/div {:style "..."}))
(update a :style #(str % "..."))oh, i just realized that h/div is a regular HTML element, so you can mutate the style on it like any HTML thing.. like (set! (.-style elem) "width:100%")