javascript中的“页面顶部”链接

Using php in a webpage and struggled with anchoring to the top, so I'm using a line of javascript to accomplish what I want. The code is:

<script language="JavaScript" type="text/javascript">
<!--
document.write("<a href= \"" + document.location + "#top\" >Top of Page</a>");
// -->
</script>

Only problem is, I want to take the code and add a:

class="bmenu"

line to it so it will be formatted the same as other links (color, font, etc.). I know nothing of javascript, so this is probably a simple thing, but would be a really helpful workaround for those who need to link to the top of a page, but have limitations as to which method they can use.

Thanks in advance!

Here's what the code looks like for those curious.

I have a .php file titled bmenu.php that contains a bottom menu that is added to every page. It contains

|&emsp;
<a href="index.php" class="bmenu">Home</a>
&emsp;|&emsp;
<a href="about_us.php" class="bmenu">About Us</a>
&emsp;|&emsp;
<a href="find_us.php" class="bmenu">Find Us</a>
&emsp;|&emsp;
<a href="contact_us.php" class="bmenu">Contact Us</a>
&emsp;|&emsp;
<script language="JavaScript" type="text/javascript">
<!--
document.write("<a class=\"bmenu\" href= \"" + document.location + "#top\" >Top of Page</a>");
// -->
</script>
&emsp;|

and then in each file that I want this menu I add

<?php include 'PHP/bmenu.php'; ?>

This saves typing and enables me to make a single edit to the menu rather than editing every page that I want that menu on every time I want to change it.

Try this:

document.write("<a class=\"bmenu\" href= \"" + document.location + "#top\" >Top of Page</a>");

Try Some animation effect-

HTML

<!DOCTYPE html>
  <html lang="en">
<head>
  <title>Title</title>
</head>
<body id="top">
      .........
      .........
      <a href="#top">Back To Top</a>
</body>

jQuery

$('a[href^="#"]').on('click',function (e) {
    e.preventDefault();
    var target = this.hash,
    $target = $(target);
    $('html, body').stop().animate({
        'scrollTop': $target.offset().top
        }, 900, 'swing', function () {
        window.location.hash = target;
    });
});