How do i capture the href instead of the google? [closed]

sorry, really a newbie at this. how do i copy the href instead of google?

<a id="test" href="https://www.google.com">Google</a>
<button onclick="copyToClipboard('#test')">Copy to clipboard</button>

function copyToClipboard(element) {
  var $temp = $("<input>");
  $("body").append($temp);
  $temp.val($(element).text()).select();
  document.execCommand("copy");
  $temp.remove();
}