Easy way of Theming in Web - The Interaction (Part II/II)

This is the second part of #-Link-Snipped-#. If you haven't read this, please check it out first and come back here, to get the context.

We are going to use jQuery to make our work simple. So, in the section, we will add a link to the jQuery library, probably from the Google APIs.
Note that we are using jQuery 1.7.2 for stability purposes. And now for the code to change, we need to add three links or buttons, which handle the theme change. So, in the HTML, lets add these three links:

HTML
CSS
.wrap.themelinks {background: #fff; border-radius: 10px; clear: both; overflow: hidden; margin-top: 25px;}
.wrap.themelinks h4 {margin: 0; padding: 10px;}
.wrap.themelinks .theme {margin: 0 10px 10px; padding: 3px 5px; display: inline-block; background: #eee; border-radius: 5px; text-decoration: none; color: #f90}
.wrap.themelinks .theme:hover {background: #f90; color: #fff;}
jQuery
$(document).ready(function(){
    $(".theme").click(function(){
        var theClass = $(this).attr("href");
        $("body").removeAttr("class").addClass(theClass);
        return false;
    });
});
Here, we are changing just the class attribute of the tag, which is supported by all the browsers. We also add a return false; to the .click() function of the link, in order not to propagate to the link specified in the href attribute of the Link 3
[*]Link 4
[*]Link 5



Welcome


A Paragraph



Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse.

A List



    [*]
    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    [*]
    Ut enim ad minim veniam, quis nostrud exercitation ullamco.

    [*]
    Duis aute irure dolor in reprehenderit in voluptate velit esse.






[/html]Working Demo

You can find the working demo at #-Link-Snipped-#.

Replies

  • ankur8819
    ankur8819
    Hi Praveen,
    Thankss for sharing the info.I was thinking of creating a customizable UI and was looking for idea similar to you posted. Was struggling for like a week now but this post has given me a heads up.
    Thank you for sharing
  • PraveenKumar Purushothaman
    PraveenKumar Purushothaman
    ankur8819
    Hi Praveen,
    Thankss for sharing the info.You was thinking of creating a customizable UI and was looking for idea similar to you posted. Was struggling for like a week now but this post has given me a heads up.
    Thank you for sharing
    Wow! Glad that it helped you. Do post your queries in this thread, will be happy to reply you! 😀

You are reading an archived discussion.

Related Posts

FoundataionDB is a new type of database system evolving that builds on the best of the NoSQL databases. The founders of FoundataionDB believe that they have a robust, infinitely scalable...
CMAI Association of India has announced India International Communications and Electronics Fair aka ICOMM 2012 to be held on 14 and 15 September 2012 at the NSIC grounds in New...
India is totally obsessed with all things 'foreign' and I'm wondering whether Indian brands really want to be identified as Indian. Has 'Made In India' become synonymous to being 'cheap'...
can u plz suggest me some important topics about digital electronics..??????????/
I am using Dell inspiron series with 512 mb ATI Radeon card. It's been around 2.75 year without a single problem at all, but Recently my laptop busted and I...