a DIV of one page (for example page01.php) flips 180° everytime that I click a specific button. In simple words, this button add or remove a class (rotator) to the DIV (rotate 180°) every time.
When I press another button to change the page (to page02.php) I need check if the DIV in page01.php has or not this class (rotator) and if this class it is applied I need to send it to the page02.php and apply the same class to another DIV to looks the same as the page01.php.
This is the Button in jQuery:
$(".btn-rotate").click(function() {
if ($("#box").hasClass("rotator")) {
$("#box").removeClass("rotator");
} else {
$("#box").addClass("rotator");
}
})
This is the DIV:
<div id="box" class="content-background bg-index">
This is the CSS of Rotator
:
.rotator {
transform: rotate(180 deg);
transform - origin: center;
}
I Was thinking to use POST and GET of jQuery but i really don't know how to send the information.
Someone could have an idea?
Thanks!
Héctor
use local storage,
$(".btn-rotate").click(function(){
if ($("#box").hasClass("rotator")){
localStorage.removeItem('btn');
$("#box").removeClass("rotator");
} else {
localStorage.setItem('btn', 'rotator');
$("#box").addClass("rotator");
}
})
and in another page check if it's rotated or no
if (localStorage.getItem('btn') === 'rotator'){
$("#box").addClass("rotator");
} else {
$("#box").removeClass("rotator");
}