Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

96
Visualizações
Randomly changing video with JS - javascript

I am a newbie, I want to show random videos when loading the website, I have found this code, change some things and achieve what I wanted, but now I need each video to have a small description and a link I attach this image I want something similar to this, is there someone here who can help me with this, thanks in advance.

https://piic.me/img-134

<video autoplay muted loop id="OracleVid" style="display: auto; max-width:100%;">
  <source id="OracleVidSRC"/>
</video>

<script>
var clip = document.querySelector("#OracleVidSRC");
var video = document.querySelector("#OracleVid");
var oracleVidArray = [
  "http://localhost/website/wp-content/uploads/2021/10/logitech1_xlarge_preview.mp4",
  "http://localhost/website/wp-content/uploads/2021/10/6b_xlarge_preview.mp4",
  "http://localhost/website/wp-content/uploads/2021/10/elementor1_xlarge_preview.mp4"
];


window.onload = function oracleFunction() {
  clip.src = oracleVidArray[Math.floor(Math.random() * oracleVidArray.length)];;
  //video.style = "display: block";
  video.load();
}

</script>

You can also see the original code here: Randomly changing video src with JS

I just want to include this in the js code above, (each video has a different url and description)

<figure class="wp-block-video">
     <a rel="noreferrer noopener" href="https://website.com" target="_blank">
          <video autoplay="" loop="" muted="" src="http://localhost/website/wp-content/uploads/2021/10/logitech1_xlarge_preview.mp4" playsinline="">
          </video>
     </a>
     <figcaption><strong><code><span style="color:#111111" class="has-inline-color">Description 
          </span></code></strong><a rel="noreferrer noopener" href="https://website.com" target="_blank">website.com</a></figcaption>
</figure>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Add class "none" in:

<figure class="wp-block-video none">

Edit css class:

.none { display:none; }

Put your code with "<figure" after code with "<video" as below:

<video autoplay muted loop id="OracleVid" style="display: auto; max-width:100%;">
  <source id="OracleVidSRC"/>
</video>

<figure class="wp-block-video none">
 <a rel="noreferrer noopener" href="https://website.com" target="_blank">
      <video autoplay="" loop="" muted="" src="http://localhost/website/wp-content/uploads/2021/10/logitech1_xlarge_preview.mp4" playsinline="">
      </video>
 </a>
 <figcaption><strong><code><span style="color:#111111" class="has-inline-color">Description 
      </span></code></strong><a rel="noreferrer noopener" href="https://website.com" target="_blank">website.com</a>

And in function oracleFunction() remove class none.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda