Quiz

  1. Is using jQuery the only way to modify the dom with JS?

    No! There are built-in ways. In fact, that's how JQ works: it provides (IMHO) a better interface to those built-in ways. I think jQuery is more clear, concise, and consistent. But that's just my opinion.

    Furthermore, the built-in ways are getting better (partly from adopting ideas from jQuery and other libraries), so jQuery will probably eventually be out of a job. But for now, I like it.

  2. I would like to talk more about jQuery's Flaw, and The Click Method.

    jQuery's flaw is also my opinion. The flaw is just that it's perfectly happy with an empty set, which is sometimes really convenient.

    
    $(".appendix").hide();   // hide the appendices, if any
    
    

    But sometimes, that means that errors are harder to catch:a

    
    $(".apendix").hide();   // hide the appendices, if any
    
    

    So, I implemented a plug-in that I like (again, personal preference):

    
    $(".apendix").some().hide();   // hide the appendices, and there must be some
    
    
  3. I would like to talk more about The Click Method.

    the click method attaches a function to a DOM element, telling the browser to invoke (run, execute) the function when the element is clicked.

    
    <button id="darkModeButton">turn on dark mode</button>
    
    

    and then:

    
    $("#darkModeButton").click(doDarkMode);
    
    

    The function does the CSS modifications that are dark mode.

  4. can you talk more about why this is an error: $("h3events").click(turnEventsRandomColor());

    Sure! We don't want to invoke the function now, maybe not at all! Instead, we want to give the function to the click method.

    What the erroneous code does is run the function and give the return value to the click method.

  5. I was stuck between b and d for answer 4, can you touch up on why we do not want to use the extra parentheses (turnBlue()) I am still a little confused on that part?

    This is very common. There's a difference between referring to a function and running it. We don't want to run it. We want to give it to someone else to run.

  6. the reading made sense / The reading was clear

    Glad to hear it!