2

Estoy creando una función pero el problema es que onmousedown ni onmouseup me funciona desde el celular, cuáles funciones debería usar para reemplazar estas y que funcione? ya que básicamente es necesario porque va a ser una app no una página web.

var record = document.getElementById("record");

record.onmousedown = function() {
record.innerHTML = "Grabando...";
record.style.backgroundColor = "red";
}

record.onmouseup = function() {
record.innerHTML = "Grabado";
record.style.backgroundColor = "green";
}
body{
height: 100vh;
margin: 0;
display: flex;
align-items: center;
justify-content: center;
}
#record{
color: #fff;
width: 100px;
height: 100px;
background-color: black;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
}
<span id="record">Grabar</span>

1 respuesta 1

4

Las funciones para celular análogas a onmouseup y onmousedown son ontouchstart y ontouchend

record.ontouchstart = function() {
record.innerHTML = "Grabando...";
record.style.backgroundColor = "red";
}

record.ontouchend = function() {
record.innerHTML = "Grabado";
record.style.backgroundColor = "green";
}

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.