Skip to main content
Used a more direct cross reference (as user names can change at any time - it actually did change in this case (or was misspelled)).
Source Link
Peter Mortensen
  • 31.4k
  • 22
  • 109
  • 132

Most answers are unnecessarily complicated.

If you just want to jump to the target element, you don't need JavaScript:

# the link:
<a href="#target">Click here to jump.</a>

# target element:
<div id="target">Any kind of element.</div>

If you want to scroll to the target animatedly, please refer to @Shahil's answer5hahiL's answer.

Most answers are unnecessarily complicated.

If you just want to jump to the target element, you don't need JavaScript:

# the link:
<a href="#target">Click here to jump.</a>

# target element:
<div id="target">Any kind of element.</div>

If you want to scroll to the target animatedly, please refer to @Shahil's answer.

Most answers are unnecessarily complicated.

If you just want to jump to the target element, you don't need JavaScript:

# the link:
<a href="#target">Click here to jump.</a>

# target element:
<div id="target">Any kind of element.</div>

If you want to scroll to the target animatedly, please refer to 5hahiL's answer.

Required prop is ID, not name. Also clarify element type is any.
Source Link
2540625
  • 11.4k
  • 8
  • 54
  • 62

Most answers are unnecessarily complicated.

If you just want to jump to the target anchorelement, you don't need javascript at allJavaScript:

# targetthe elementlink:
<a name="target"><href="#target">Click here to jump.</a>

# thetarget linkelement:
<a<div href="#target">Target<id="target">Any kind of element.</a>div>

If you want to scroll to the target animatedly, please refer to @Shahil's answer.

Most answers are unnecessarily complicated.

If you just want to jump to the target anchor, you don't need javascript at all:

# target element:
<a name="target"></a>

# the link
<a href="#target">Target</a>

If you want to scroll to the target animatedly, please refer to @Shahil's answer.

Most answers are unnecessarily complicated.

If you just want to jump to the target element, you don't need JavaScript:

# the link:
<a href="#target">Click here to jump.</a>

# target element:
<div id="target">Any kind of element.</div>

If you want to scroll to the target animatedly, please refer to @Shahil's answer.

Source Link
Brian
  • 31k
  • 15
  • 89
  • 88

Most answers are unnecessarily complicated.

If you just want to jump to the target anchor, you don't need javascript at all:

# target element:
<a name="target"></a>

# the link
<a href="#target">Target</a>

If you want to scroll to the target animatedly, please refer to @Shahil's answer.