Skip to content

Commit

Permalink
Modify the sample code in the Location hash property (#37022)
Browse files Browse the repository at this point in the history
* Modify the sample code in the Location `hash` property

* Update index.md

* Apply suggestions from code review

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update files/en-us/web/api/location/hash/index.md

* Update files/en-us/web/api/location/hash/index.md

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update files/en-us/web/api/location/hash/index.md

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update files/en-us/web/api/location/hash/index.md

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: wbamberg <[email protected]>
  • Loading branch information
3 people authored Jan 7, 2025
1 parent 0f7aca6 commit 6033c36
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions files/en-us/web/api/location/hash/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ A string.

## Examples

```html
<a id="myAnchor" href="/en-US/docs/Location.href#examples">Examples</a>
<script>
const anchor = document.getElementById("myAnchor");
console.log(anchor.hash); // '#examples'
</script>
Assuming the user has navigated to `https://example.org#examples`, the following code will log `#examples`:

```js
const result = location.hash;
console.log(result);
```

## Specifications
Expand Down

0 comments on commit 6033c36

Please sign in to comment.