Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add exercise to turn on/off CSS themes with JS on practice page #16

Open
cfarm opened this issue Jun 25, 2016 · 2 comments
Open

add exercise to turn on/off CSS themes with JS on practice page #16

cfarm opened this issue Jun 25, 2016 · 2 comments
Labels

Comments

@cfarm
Copy link
Owner

cfarm commented Jun 25, 2016

https://cfarm.github.io/gdi-intro-js/js101-downloads/practice.html

class2 event exercise

@cfarm cfarm added the ready label Oct 1, 2017
@cfarm
Copy link
Owner Author

cfarm commented Oct 1, 2017

exercise solution

// <link href="css/bootstrap.css" rel="stylesheet">

var button = document.getElementsByClassName('btn')[0];

function changeStylesheet(event) {
    var stylesheet = document.getElementsByTagName('link')[0];
    
    if (stylesheet.href == 'file:///path/to/js101-downloads%206/css/bootstrap.css') {
        stylesheet.href = 'css/bootstrap-386.css';
    } else if (stylesheet.href == 'file:///path/to/js101-downloads%206/css/bootstrap-386.css') {
        stylesheet.href = 'css/geo-bootstrap.css'
    } else {
        stylesheet.href = 'css/bootstrap.css';        
    }

    console.log(stylesheet.href);
}

function changeHeadline(event) {
    var headline = document.getElementById('headline');
    var stylesheetPath = document.getElementsByTagName('link')[0].href;
    headline.innerHTML = 'changed stylesheet to ' + stylesheetPath;
    console.log(headline);
}

// button.onclick = changeStylesheet;
// button.onclick = changeHeadline;

button.addEventListener('click', changeStylesheet);
button.addEventListener('click', changeHeadline);

@cfarm
Copy link
Owner Author

cfarm commented Oct 1, 2017

use in Events lesson and reduce dom style attributes exercises/slides

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant