The issue lies in the fact that your getNumber() function is only triggered after a click event. It should also be executed during the page load process.
One way to solve this problem is by calling the function getNumbers() immediately after its declaration, as shown below:
var link = document.getElementById('getNumber'); // Retrieve the link element
link.onclick = getNumber; // Assign the function to run on click
function getNumber() {
var minNumber = 0; // Specify the minimum number
var maxNumber = 100; // Define the maximum number
var randomnumber = Math.floor(Math.random() * (maxNumber + 1) + minNumber); // Generate a random number
$('#myNumber').html(randomnumber); // Set the content of <div> to display the number
return false; // Return false to clean up
}
getNumber(); // Call the method here to ensure it runs when the script loads
// This will achieve the desired functionality