jquery - Check which stylesheet is active and hide a div -


I currently have a topic that switches between the 2 main stylesheets.

The integral part of a single element is the design that can not be stylized with CSS, so I decided to toggle visibility between 2 different versions with appropriate colors. (This is a tag cloud that is loaded by JavaScript; one version matches the color of the theme first and the second edition corresponds to the color of the other theme.) I am adding a very simple code to make the panel switch :

 Show ("fold"); $ ('# Green'). Hide ("fold") ($ ('' # pink ''). ("Fold"); $ ('# pinkcloud'). ("Fold") to hide;});});   

(There are links to links to click to change # Green and # Pink ID.)

The problem is, the subject operates on cookies, Therefore, remember that the topic you chose is not divisible, so by default no load is loaded automatically what the topic misses your browser < P> What I will add to my code to make sure And it checks which stylesheet is active and when it loads it shows the appropriate division? How do I check in my JavaScript, for which file he is currently reading?

I'm terribly grateful to things sometimes, so this topic is so that you can actually see what I mean (). To see the problem, click on the green theme option, refresh the page, and see the clipping section, which will be pink. To show a properly colored section you can click on the green theme option again, but I obviously like to show one.

The code may be located for theme switching, so you can see how it works.

Yes, you need to store some values ​​in a cookie that will switch between stylesheets That information can be preserved

Therefore, my work may be difficult and some testing may be required, but first of all I have a very good and light cookie plug-in

Then you need some jquery on these lines:

  $ (window) .on ('load', funct ion () {$ .cookie ('cookieName', 'green', {path: '/', termination: 365}); // Set the default as root document for 1 year.}); Click $ (document) .ready (function () {$ ('# pink') (function () {$ .cookie ('cookie name', 'pink', {path: '/', expiry: 365}) ; // click}}; $ ('# green') click (function () {$ .cookie ('cookie name', 'green', {path: '/', ends: 365}) ; // Reset root}};});   

Then I will add a stylesheet to the head of the document and give it an ID

     

Then you can toggle a if Statement is required.

  if ($ .cookie ('cookiename') === 'green') {$ ('#cssToggle') .attr ('href', 'http: //yoursite.com) /css/green-style.css')} and if ($ .cookie ('cookie name') === 'pink') {$ ('#cssToggle') .attr ('href' , 'http: // youiteite .com / css / pink-style.css')}   

I can be completely elliptical, but can be more elegant solutions, but I believe this will work. I will try and I am going to test it.

Edit: Crude example is working here:

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -