Is there a way to set an image src conditionally based on a variable?
Example.
I’m using a variable on the page toggling a menu. The menu has an icon " >
" when closed
and when the menu is open I want to display a different icon " <
"
I was hoping to set that based on the same variable I’m using to display the menu.
Pseudo code
variable == 0 img source 1
variable == 1 img source 2
But the dynamic attribute for image src doesn’t take conditions from what I can tell. Not sure if there’s a way to do this easily? Hoping to avoid using two img elements and toggling their visibility with a condition.
Been searching the forum, but couldn’t find much talk about it, so I might just be missing something very obvious.