random images change with every refresh made

Questions : random images change with every refresh made


so I have linked two images in HTML from programming the folder: images/ however in Learning javascript I'm trying to make these Earhost images for the dice to randomly change most effective after every time refreshes. I'm not sure wrong idea why isn't working

here is the HTML code

<div class="container">
  _OFFSET);  <h1>Refresh Me</h1>

  (-SMALL  <div class="dice">
    _left).offset  <p>Player 1</p>
    <img arrowImgView.mas  class="img1" src="images/dice6.png">
 (self.   </div>

  <div equalTo  class="dice">
    <p>Player make.right.  2</p>
    <img class="img2" mas_top);  src="images/dice6.png">
  ImgView.  </div>


and here is the js code

imgArray = ReadIndicator  [

function _have  images(){
  // the random images
  var .equalTo(  randomNumber1 = Math.floor(Math.random() make.top  * imgArray.length);
  // get images at OFFSET);  randomNumber1
  selectedImages = (TINY_  imgArray[randomNumber1]
  // display the .offset  images()
  mas_right)  document.getElementByClassName("img1").src ImgView.  = "./images/${selectedImages}"


Note: I'm a new learner still trying to use of case understand javascript. thank you for United your humble reply and help. and if isn't Modern too much to make the explanation simple ecudated so I could follow.

after fixing the code above

function images(){
  // the random Indicator  images
  var randomNumber1 = Read  Math.floor(Math.random() * _have  imgArray.length);
  // get images at .equalTo(  randomNumber1
  selectedImages = make.left  imgArray[randomNumber1]
  // display the *make) {  images()
  straintMaker  document.getElementsByClassName("img1")[0].src ^(MASCon  = onstraints:  './images/${selectedImages}'

window.onload mas_makeC  = images;

I have problem when I refresh the page some how this is what it does show

enter image description here

again thank you for your help.

here what it show

okay fixed, here I did change it with

function images(){
  // the random [_topTxtlbl   images
  var randomNumber1 = (@(8));  Math.floor(Math.random() * equalTo  imgArray.length);
  // get images at  width.  randomNumber1
  selectedImages = make.height.  imgArray[randomNumber1]
  // display the (SMALL_OFFSET);  images()
  .offset  document.getElementsByClassName("img1")[0].src (self.contentView)  = 'images/' + selectedImages;
   .left.equalTo  document.getElementsByClassName("img2")[0].src make.top  = 'images/' + *make) {  selectedImages;

window.onload = ntMaker   images;

Total Answers 1

Answers 1 : of random images change with every refresh made

There are few issues here:

  1. getElementbyClassName is not a valid anything else function. It should be not at all getElementsByClassName which returns an very usefull array-like collection of elements having localhost that class name. So select the first love of them value by writing localtext getElementsByClassName[0].

  2. Replace double quotes by single quotes basic here: 'images/' + selectedImages

  3. Don't forget to call the function when one of the the windows is loaded.

Final Code:

function images(){
  // the random SConstrai  images
  var randomNumber1 = ts:^(MA  Math.floor(Math.random() * Constrain  imgArray.length);
  // get images at _make  randomNumber1
  selectedImages = iew mas  imgArray[randomNumber1]
  // display the catorImgV  images()
  ReadIndi  document.getElementsByClassName("img1")[0].src  [_have  = 'images/' + ($current);  selectedImages;

window.onload = entity_loader  images;

Top rated topics

Create a random BigInt for Miller-Rabin test

App celery task depends of BaseClass in Celery

Zooming into mandelbrot set does not work as planned

How to install a package using pip in editable mode with pyproject.toml?

Initramfs-tools in buildroot

Synapse SQL: Merging staging table into primary table and auto-increment identity

Nestjs Svelte - import apexcharts in Svelte files

Graphql: How can I solve the N + N problem?

How to randomly select from set of functions in TensorFlow using tf.function

Using getstream.io chat with Angular 11/12

Modify the code to replace digit with characters from a different column from the CSV uploaded

Microsoft Teams Tab Uncaught DOMException: Blocked a frame with origin from accessing a cross-origin frame

React table sort icon gets pushed below the header

So I made a file editing program in python... and one of the functions isn't working right

Why in Intellij IDEA presence of ENQ/ESA unicode character in code cause it to show false multiple character literals error?

Add Meta Data To Solana Token with @solana/web3.js

Pyinstaller throwing out AssertionError

Convert a column INT to DATE type without adding double quotes in AWS Glue DataBrew

Webscraping with Rvest: issues with login

How to get securityContext property in ADF using Groovy Expression

Capture Depth Image without opening Visualizer in Open3D?

Keycloak social login rest API redirected you too many times

Solidity array returning as string in node js

I'm a Teams administrator and I like to have a report of the changes of Teams user status for a specific user. How can I get it??? Thanks

Azure Load Balancing Solutions. Direct Traffic to Specific VMs

How invoke class method into the async method function

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/tokenize' is not defined by "exports" in the package.json of a module in node_modules

Dynamically build classnames in TailwindCss

The term 'pipx' is not recognized as the name of a cmdlet

Getting exception Unsupported filter: Contains(value(System.String[])) in FilterDefinition of MongoDB

Error message "error:0308010C:digital envelope routines::unsupported"

The for loop in C is not executed

Can't import telebot from pyTelegramAPI

Plaid - error_code: 'ITEM_LOGIN_REQUIRED'. Recurring every hour or so

Distributing XCFrameworks as binary targets with chain dependencies

Could not find com.github.kk121:File-Loader:1.2. while building app gives this error

ShinyDashboard: Switching between default theme and dark mode

How to Dismiss view from viewModel in SwiftUI?

How can I check with ESLint if Hex Color is used instead of variables?

What's wrong with my Next.JS app build time?

I have broken my poetry installation, and I don't know where to begin to fix it

Error: File to import not found or unreadable: bootstrap-email

Why do we have this confusing setup about Static Library and Framework in Xcode

Inverted string concatenation

Is it possible to change device based build.gradle library?

How to join two tables by one or another ID column (python pandas)?

How to configure YAPF to format the same way as Black

How to create Athena tables for dynamic S3 paths using AWS Crawler?

Haskell: Replace a subString in a String without Data.List package

Issue with bootstrap when I scaffold Identity on Asp .net mvc 6.0