Tuesday, April 1, 2014

JQuery

I tried out the toggleClick function but I wasn't able to get it working so I moved on to the lesson. I've finished most of the lesson and I'm hoping that by the end of it I may be able to fix my game.

This lesson mainly talked about messing with the html using JQuery
  • $(document).ready(function() {
        $("#text").click(function() {
            $(this).addClass("highlighted")
        });
    });
    • For example this function adds a class to text which adds CSS to it giving it a highlighted effect(removeClass does the opposite)
  • $(document).ready(function () {
        $("body").append("<p>I'm a paragraph!</p>");
    });
    • This simply adds a paragraph to the end of the body, alternatively prepend would put it at the start
  • remove gets rid of an element completely while empty gets rid of its contents

1 comment:

  1. I'm determined to get .toggleClick working. Please:

    1. Point me to the source files you are using that are not working.
    2. Describe the desired behavior you want the page to have.

    I'll take a look at it while I'm in Montreal.

    ReplyDelete