jQuery Homework

All answers should only use jQuery calls and methods. I suggest using the jQuery API to lookup the answers you don't know!

1. I have a div element <div id="target"> on my page with an id "target". I want to fill it with my ajax search result, but first I want to clear it of all its content/children (e.g., remove everything). How can you do this with jquery? Hint, the answer looks like this: $(selector).foo()

What is the selector, and what is the function (it's not called foo!)?


2. How would I add a paragraph <p> that says "hello world" as a child to all of the <div> tags on my page?


3. How do I retrieve the text that a user has typed into a form's text box that has ID "targetBox"? I'm looking for a single method name to replace foo here: $("#targetBox").foo()


4. In a short phrase, explain what the .html() method does. For instance: $("p#target").html()