SRy
SRy

Reputation: 2967

Applying different style sheets dynamically into a layout

I have a layout in which i have to apply different extrenal stylesheets based on the condition selected in the home page.Condition is i have to select a user from the dropdown in the home page, based on the user selected in the home page I have to dynamically load extrenal css files and apply it to the layout.I am using Jquery. How can i do this in jquery.

Upvotes: 0

Views: 240

Answers (1)

Sudhir Bastakoti
Sudhir Bastakoti

Reputation: 100175

Do you mean something like:

$(document).ready(function() {
    $("#yourSelectId").change(function() {
        if($(this).val() == "something") {
            //load css
            var styleUrl = "some_stylesheet_url.css";
            $('<link rel="stylesheet" type="text/css" href="'+styleUrl+'" >')
            .appendTo("head");
        }
    });
});

Upvotes: 1

Related Questions