jquery / jquery/learn.jquery.com

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

Open
#739 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Chapter: plugins
Dominant language
JavaScript
Stars
915
Forks
471
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open the Basic Plugin Creation lesson at the linked URL and compare the final optimized example with the preceding and first Putting It Together examples. Update the example and the note about retrieving href so the displayed result and explanation agree, then verify the lesson examples produce the documented output.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, jquery
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.