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 https://wix.to/94BuAAs 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.
Thanks GOS. I always appreciate your answers but I think we are talking past each other. I have 4 selectionTags. Each selectionTags have 4 tags. Each slide contains 1 selectionTags. I want to pass each selectionTags to the two functions above with their tags as seperate functions.
With this line here.
$w(`#${SelectionTags}`).onClick(() => {
This needs to be your Selection Tags element.
$w("#myElement").onClick( (event) => {
https://www.wix.com/corvid/reference/$w.SelectionTags.html
https://www.wix.com/corvid/reference/$w.SelectionTags.html#onClick
https://www.wix.com/corvid/reference/$w.SelectionTags.html#selectedIndices
Tags example.
https://www.wix.com/corvid/example/filter-with-multiple-options