Recently, I've been working on a document that features a top navigation with 4 different links. Each time a link is clicked, a div right below it changes its size accordingly. My goal now is to implement the use of cookies to remember the last selected link.
Here is the code snippet for the links:
<li><a href="#" class="desktop">Desktop</a></li>
<li><a href="#" class="tablet">Tablet</a></li>
<li><a href="#" class="tabletP">Tablet (P)</a></li>
<li><a href="#" class="mobile">Mobile</a></li>
Next up, we have the jQuery code responsible for controlling the behavior of the div:
$(document).ready(function () {
$(".desktop").click(function() {
$(".iframe").animate({"width" : "100%"},{queue: false, duration: 1000 });
$(".iframe").animate({"height" : "100%"},{queue: false, duration: 1000 });
});
// Other click functions for tablet, tabletP, and mobile
});
I am currently using the jQuery Cookie Plugin to create and manage the cookie. Here's an example of how I'm implementing it along with the jQuery code:
// Code snippets for each link click event setting a cookie
Now, my task involves reading the created cookie to automatically select the corresponding link and adjust the div size as needed.
While exploring similar queries, I came across this discussion, which seemed relevant. However, the suggested code in that thread appears somewhat complex.
Below is an excerpt from that discussion showcasing how cookies are utilized to remember link selections:
// Sample code from the mentioned discussion
If anyone could provide guidance on how to effectively read and utilize the cookie value to auto-select the appropriate link, I would greatly appreciate it.
I trust this explanation clarifies my requirements.