I am trying to create a dark theme on my MVC application.
I already have a theme saved which the application uses when it starts
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap-simplex.css" />
Below is my js on my site.js file
function updateStyleSheet(filename) {
newstylesheet = "Content/" + filename + ".css";
if ($("#dynamic_css").length == 0) {
$("head").append("<link>")
css = $("head").children(":last");
css.attr({
id: "dynamic_css",
rel: "stylesheet",
type: "text/css",
href: newstylesheet
});
} else {
$("#dynamic_css").attr("href", newstylesheet);
}
}
below is what i use on my _Layout.cshtml page which is the theme i want to switch to.
<input type="button" onclick="updateStyleSheet('bootstrap-slate')" value="Dark Mode">
I cant seem to get the switch of theme's to work, does anyone have any ideas why?