Forum Discussion
Changing state directly from JavaScript?
Here you can see a video of it working.
https://www.linkedin.com/posts/mathnotermans_tls-storyline-articulate-activity-7192804804962734080-CuGq?utm_source=share&utm_medium=member_desktop
This code does the work.let baseElement = document.querySelector("[data-acc-text='myElement']");
let parent = baseElement.parentNode;
let allDIVS = parent.getElementsByTagName("div");
showState();
function showState(){
for (let i = 0; i < allDIVS.length; i++) {
let dataModelID = allDIVS[i].getAttribute('data-model-id');
if(dataModelID != null ){
if(i==0){
allDIVS[0].classList.remove('hidden');
allDIVS[0].classList.add('shown');
}else{
allDIVS[i].classList.remove('shown');
allDIVS[i].classList.add('hidden');
}
}
}
}
As said in the video... the way you make your states matters !