Skip to content

Place of return statement in a jQuery plugin in code snippet | Chapter 8 Web Patterns #2

Description

@imrek

On p. 178 your book provides an example of a jQuery plugin like this:

$.fn.yeller = function () {
    this.each(function (_, item) {
        $(item).val($(item).val().toUpperCase());
        return this;
    });
}

Shouldn't it actually return this only once after the loop (instead of every iteration) or, better yet, return this.each(), as in the documentation.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions