Add CSS when clicking a button that goes to another page

1

I need to add height in a div when I click a button, but it has a but this div is on another page and that's what I'm not able to do, I'll show you how I did it in the code below if anyone can help. p>

CODE

$('.close-reveal-modal').click(function(){
    $('#site .makingof .slide').addClass('insere-altura');
});​

Explaining the code: When I click on .close-reveal-modal it returns to the index.php page and inserts the "insert-height" class together with the slide class.

    
asked by anonymous 23.05.2015 / 00:27

1 answer

1

It's a bit tricky getting this behavior with just javascript

One solution would be to use localStorage:

  • Record some type of information in localstorage and in the index page check the localstorage if the information is present add the class. Ex:

// No Index
$(function(){
  if(localStorage.getItem('close-reveal-modal-clicked')){
       $('#site .makingof .slide').addClass('insere-altura');
  }
});


$('.close-reveal-modal').click(function(){
  localStorage.setItem('close-reveal-modal-clicked', true);
});​
    
23.05.2015 / 00:45