Gallery

Mostrando entradas con la etiqueta onclick javascript. Mostrar todas las entradas
Mostrando entradas con la etiqueta onclick javascript. Mostrar todas las entradas

jueves, 13 de junio de 2024

JS - Audio en tu sitio con boton onclick

IMAGEN FIJA EN WEBSITE CON FUNCION ONCLICK
play and stop

Código para copiar y pegar

<img src="img/pedro_pe.png" alt="Capibara" title="Capibara Song" style="height: 45px; position: fixed; right: 2%; top: 44%; cursor: pointer; border-radius: 50%;" onclick="playSound('sound2')" >

<audio id="sound2" src="media/pedro-pe.mp3"></audio>

 

function playSound(sound2) {

  var song1 = document.getElementById(sound2);

  song1.volume = .25; // setting the volume to 25% because the sound is loud

  if (song1.paused) {  // if song1 is paused

    song1.play();

  } else {

    song1.pause();

  }

}

sábado, 1 de abril de 2023

Javascript - Interacción con sitio web

 Javascript - Saludarte por la mañana con JS, ejercicio "onclick" en "alert"


HTML
<p onclick="saludar()" id="hola">Saludate, escribe tu nombre</p>

JAVASCRIPT
function saludar(){
    let saludar = prompt("Hola, Como te llamas?");
    let nombre = saludar;
    document.getElementById("hola").innerHTML = 'Hola ' + nombre + ',
que tengas un excelente día';
}

Javascript - Onclick

Ejercicio "onclick" de Javascript


HTML

<p onclick="alert('Here I am')">Aquí irá onclick</p>

Tan simple como eso.

Documental de Hackers