[solved] Dojo question : select/deselect dices
Posted: 01 May 2020, 13:50
Hi,
I've got 5 dices :
And I would like to add or remove the class "dice_selected" when I click on it.
In the setup part, I've put :
and I add a "onSelectDice" function :
It works great.
But I would like to "switch" (add if the class doesn't exist and remove if the element already have the class "dice_selected").
How can I do this ? How can I know on which of the five dices the function has been called ?
Thank you,
Axel
I've got 5 dices :
Code: Select all
<div id="dice_1" class="dice" style="left:10px; top :10px;"></div>
<div id="dice_2" class="dice" style="left:120px; top :10px;"></div>
<div id="dice_3" class="dice" style="left:230px; top :10px;"></div>
<div id="dice_4" class="dice" style="left:340px; top :10px;"></div>
<div id="dice_5" class="dice dice_selected" style="left:450px; top :10px;"></div>In the setup part, I've put :
Code: Select all
dojo.connect( $('#dice'), 'onclick', this, 'onSelectDice' );Code: Select all
onSelectDice: function(evt) {
console.log("onSelectDice ");
},But I would like to "switch" (add if the class doesn't exist and remove if the element already have the class "dice_selected").
How can I do this ? How can I know on which of the five dices the function has been called ?
Thank you,
Axel