Creating HTML Elements


#1

Why isn't this working?

$(document).ready(){
    $h1=$("<h1>Hello.</h1>");
});

I keep getting a message saying I didn't create the variable $h1.


#2

function() is missing in document.ready()


#3

That worked. I was able to get through the other exercises without that portion, though.


#4

That is because the lesson checker didn't expect it, and it was not needed. From here on you will be using the callback that .ready depends upon to handle the document content loaded event.

.ready() is a listener. Listeners are not able to handle the events they hear, so must hand off that task to another function. That is why,

$(document).ready(function () {
    // handler code
});

#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.