Hi,
I’m making an FAQ page with expand and collapse function, with icons serving as the trigger button. I’d like to know if I can set the icon to change to another icon on click.
So basically changing from: ▸ To: ▾ on click.
Is this possible?
Any help/advice would be appreciated.
Thank you Ajit. I found what I was looking for. My button changes from ▸ To: ▾ on click. Now I need it to change back from ▾ back to ▸ on the second click. Any idea how that would work?
Assign a variable for checking how many clicks have been instituted →
#vectorImage2 - The vector image
$w.onReady(function () {
let clicks = 1;
$w('#vectorImage2').onClick((event) => { //vector image
clicks = Number(clicks) + 1;
console.log(clicks);
if (clicks % 2 === 0) {
$w('#vectorImage2').src = "wix:vector://v1/e033af19096e0d6c6dd519476a38e709_svgshape.v1.Tree11.svg/Beach%20Tree.svg";
}
if (clicks % 2 === 1) {
$w('#vectorImage2').src = "https://mdn.github.io/learning-area/html/multimedia-and-embedding/adding-vector-graphics-to-the-web/star.svg";
}
});
});