Skip to content

jQuery Event Basics / Extending Events to New Page Elements code incorrect #584

@rhumborl

Description

@rhumborl
// Now create a new button element with the alert class. This button
// was created after the click listeners were applied above, so it
// will not have the same click behavior as its peers
$( "button" ).addClass( "alert" ).appendTo( document.body );

This is a selector to access the existing buttons, not creating a new element. Code should pass HTML:

$( "<button>" ).addClass( "alert" ).appendTo( document.body );

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions