Are you certain the error is
undefined href attribute value? I can't see where you are including the JQuery Library.
When I try your code (
JSFiddle) I see the error
Uncaught ReferenceError: $ is not defined.
The error goes away if I add the following line to your header section or, change the
JSFiddle Language, Frameworks & Extensions... from "
JavaScript + No-Library (pure JS)" to "
JavaScript + JQuery 3.4.1" the error is resolved.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>