Skip to content

The last example on "How to Create a Basic Plugin" returns a different result than the previous example. #739

Open
@Jeff-Schafer

Description

@Jeff-Schafer

The last example on https://learn.jquery.com/plugins/basic-plugin-creation/ says:
"Our plugin can be optimized though:"
and shows the "optimized" code.

But the example before it, when run, just appends the text in the href for that tag, & this "optimized" code appends the full path to where the .html file is to what is in the href for that tag.

The first example under the "Putting It Together" correctly appends "page.html" to the text between the tags.
---> Foo (page.html)

Using a local .html file (like on the Desktop), the "optimized" returns:
---> Foo file:///C:/users/..../Desktop/page.html (without the parentheses, unlike in the first example).

Below the last example, it says:
"Notice also that we're not using the .attr() method to retrieve the href attribute, because the native DOM API gives us easy access with the aptly named href property."

To make it have the same results as the first example in this section "this.href" needs to be replaced with "$(this).attr("href")".

This will contradict the text mentioned above ("not using the .attr() method"), and needs to be updated.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions