It boils down to the very basic of jQuery, the Selectors. Do you understand the relation between:
<button id = "button">
and
$('#button')
? If not, head over to
jQuery Selectors[
^]. Once you learn how the jQuery selector work, apply it to your code. Let say you want the answer to be displayed in the h1 tag,
<button id = "button">test</button>
<h1 id="answer">the answer</h1>
<script src='https://code.jquery.com/jquery-3.1.0.min.js'></script>
<script>
$('#button').on('click', function() {
var $answer = $("#answer");
var randomAnswer = Math.random();
$answer.text(randomAnswer);
});
</script>