Good day! Tell me how to implement a picture change when hovering, here is my current code, but it does not work:

<php $Image = '/image/'.$row['image']; $Image2 = '/image/'.$row['image2']; ?> <img src="<?echo $Image;?>" alt"image" onmouseover="this.scr='<?echo $Image2 ?>'" onmouseout="this.scr='<?echo $Image ?>'"> 
  • 2
    onmouseover="this.scr='<?echo $Image2 ?>'" => this.src , not this.scr - Vasily Barbashev
  • I apologize for the carelessness. Half a day I broke my head. - Newcomer

2 answers 2

 <img id="img" src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcS7RxMBcEplU5w3MpfIXdlm7Iwsn2OVCwD6JaEd2XvVvGu8WzsU2w" onmouseover="this.src='https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcTJMaenY_EGpd7uez2-t5dn_LBd6UHCgIx6NYdFE_1SWjlLF47e'" onmouseout="this.src='https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcS7RxMBcEplU5w3MpfIXdlm7Iwsn2OVCwD6JaEd2XvVvGu8WzsU2w'" alt="" /> 

Those. your code will be like this:

 <php $Image = '/image/'.$row['image']; $Image2 = '/image/'.$row['image2']; ?> <img src="<?echo $Image;?>" alt"image" onmouseover="this.src='<?echo $Image2 ?>'" onmouseout="this.src='<?echo $Image ?>'"> 

    Was inattentive, here is the end result:

     <php $Image = '/image/'.$row['image']; $Image2 = '/image/'.$row['image2']; ?> <img src="<?echo $Image;?>" alt"image" onmouseover="this.src='<?echo $Image2 ?>'" onmouseout="this.src='<?echo $Image ?>'">