Skip to main content
andreleal
Inspiring
June 30, 2015
Question

Toggle Hide/Show JS

  • June 30, 2015
  • 1 reply
  • 579 views

Ok, I used a small JS so that the training assistants can apply quickly a toggle Hide/Show an image without going to create advanced actions, etc. Very simple:

function showHide(parameter, parameter2, parameter3){

if(parameter.style.visibility == 'hidden'){

     parameter.className=parameter2;

     parameter.style.visibility='visible';

}

else

{

     parameter.className=parameter3;

     parameter.style.visibility='hidden';

}

And from CP they type in the JS button, showHide(nameImage, blurIn, blurOut);

All working everything it´s fine, but the fact is what if I have 3 or more buttons I would like to hide all the elements that are visible from the first button and then show the elements of the second button, usin Jquery then I´m using the selector:

$('canvas[id*="Image"],canvas[id*=Text_Caption_]').each(function(i, el){

  if(this.className == 'blurIn'){

  this.style.visibility='hidden'

  this.className='blurOut'

  }else{}

  })

And do not work, I dont want to use a interval to hide all the objects I would like to try another method and I´m smashing my head on the table, already try a few options without success any CPJS expert can help me out?

    This topic has been closed for replies.

    1 reply

    Lilybiri
    Legend
    June 30, 2015

    Do you really think it would not be easier with shared actions? You group all the objects, and the shared action will probably need only one parameter, the image. I have that shared action in the library I use all the time in all my projects.

    andreleal
    andrelealAuthor
    Inspiring
    June 30, 2015

    Thanks Lilybiri‌ but we are looking for a solution like that because it´s our workflow here, to make the things easier for future modification of dynamic animations, again thanks!

    TLCMediaDesign
    Inspiring
    June 30, 2015

    I'm a little confused on the second part where you are using jQuery. I don't fully understand what you are trying to accomplish.