14 lines
463 B
JavaScript
14 lines
463 B
JavaScript
|
function toggleTheme() {
|
||
|
// Obtains an array of all <link>
|
||
|
// elements.
|
||
|
// Select your element using indexing.
|
||
|
var theme = document.getElementsByTagName('link')[0];
|
||
|
|
||
|
// Change the value of href attribute
|
||
|
// to change the css sheet.
|
||
|
if (theme.getAttribute('href') == '/css/mystyle.css') {
|
||
|
theme.setAttribute('href', '/css/galactic.css');
|
||
|
} else {
|
||
|
theme.setAttribute('href', '/css/mystyle.css');
|
||
|
}
|
||
|
}
|