jquery - how to direct a link to a page and then add class to the body of that page after it is loaded? -
I am working on a template that has many different layouts with blog.html
The file is: <2 column layout
I blog.html Is styled so that when I add body tags to a specific square, each layout is displayed. Therefore, when the user clicks the link of each layout in the menu menu, the classes are added to the body tags. The Jquery code is:
$ ('.av. Fulll-width'). Click (function (e) $ {'(body'). AddClass ('blog-full width'); E.preventDefault ();});
It works well only when I am on a blog page but I can not do it from other pages I mean, I use jquery How to do, when I click on the 'full-width blog' link in the NAV menu on the index page, go to the link blog page and then add 'blog-full-width' to the body Blog.html tag.
There are several ways:
-
Store the class in session storage (or local storage if you want it to continue) and see the page for it and apply it Web Storage.
-
Store it in a cookie (if possible, avoid it!) And see the page for it and apply it.
You will make notes about all those common facilities that have to make a change on the target page, you can not have a link Which changes the current window when clicked and then runs some new code on the new page in the window. (If you were opening new windows, but I think you are not.)
Comments
Post a Comment