You didn’t include jQuery in your code:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="https://stackoverflow.com/questions/43397734/temp.js"></script>
Make sure it is included before the first reference to jQuery
.