Este artigo descreve o método do JS para acionar o efeito do jitter da imagem, acionando o mouse. Compartilhe para sua referência. O método de implementação específico é o seguinte:
Copie o código da seguinte forma: <html>
<head>
<title> Mouse desencadeia o efeito de jitter de imagem </title>
<estilo>
.ShakeImage {
Posição: relativa
}
</style>
<Script Language = "JavaScript1.2">
// Configure o grau Shake (onde # maior é igual a maior shake)
var refletor = 3
///////// EDITISTA ENDO
var stopit = 0
var a = 1
função init (que) {
Stopit = 0
shake = qual
shake.style.left = 0
shake.style.top = 0
}
função rattleImage () {
if ((! document.all &&!
Retornar
if (a == 1) {
shake.style.top = parseint (shake.style.top)+reitor
}
else if (a == 2) {
shake.style.left = parseint (shake.style.left)+reitor
}
else if (a == 3) {
shake.style.top = parseint (shake.style.top) -rector
}
outro{
shake.style.left = parseint (shake.style.left) -rector
}
se (a <4)
a ++
outro
a = 1
setTimeout ("rattleImage ()", 50)
}
função stoprattle (que) {
Stopit = 1
qual.style.left = 0
qual.style.top = 0
}
</script>
</head>
<corpo bgcolor = "#f7f7f7">
<p align = "Center">
<img src =/imagens/skinslogo.gif onmouseover = "init (this); rattleImage ()" onmouseout = "stoprattle (this)">
<br>
Mova o mouse para ver o efeito! </p>
</body>
</html>
Espero que este artigo seja útil para a programação JavaScript de todos.