Hi, I have 4 selectiontags and I want to initiate a if condition when each one of them is clicked on but it says "TypeError $w(…).onClick is not a function
// For full API documentation, including code examples, visit Velo API Reference - Wix.com
var prevSelectedValue = null ;
const selectedTags = ;
const tagIds= [ “#selectionTags1” ];
$w.onReady( function () {
//TODO: write your page related code here…
tagIds.forEach(SelectionTags => {
// Set the action that occurs when a user clicks the answer button.
$w(#${SelectionTags}
).onClick(() => {
// Add the answer to the global selected answers list.
selectedTags.push(SelectionTags);
})
})
if (selectedTags.value.length === 1 ) {
prevSelectedValue = selectedTags.value[ 0 ];
} else if (selectedTags.value.length > 1 ) {
selectedTags.value = ;
}
});
export function selectionTags1_change(event) {
//Add your code for this event here:
if (!event.target.value || event.target.value.length === 0 ) {
event.target.value = [prevSelectedValue];
} else {
event.target.value = event.target.value.filter(x => x !== prevSelectedValue);
prevSelectedValue = event.target.value[ 0 ];
}
}
I want to pass each #selectionTags (1 to 4) through these two functions.