jQuery Constructor Demo

First Paragraph, no class defined.

Second Paragraph, with a class and internal span.

Third Paragraph with an ID.

Div with span won't get highlighted.

JavaScript Source

/* Callback constructor */
jQuery(function() {
    /* Selector constructors */
    var paras = $("p").css("font-weight", "bold");
    $(".second").css("font-size", "1.3em");
    
    /* Using context to constrain the selector */
    $("span", paras).css("background-color", "silver");

    /* Constructor using an element */
    var third = document.getElementById("third");
    $(third).css({"border" : "1px solid black", "width":"200px"});

    /* Constructor using an html snippet */
    $("<p>Fourth paragraph created on the fly.</p>").appendTo("#example");
});