Changing background image when hovering on a list item

前端 未结 4 1970
耶瑟儿~
耶瑟儿~ 2020-12-19 04:37

As you can see in the screenshot, I\'ve got an unordered list. Now the div of this list has a background image. What I want to do is to change background\'s ima

4条回答
  •  独厮守ぢ
    2020-12-19 04:53

    Using the method shown in the following code snippet, you would have the onmouseover attribute both A: Store the source of the image assigned to each list-item to a variable respectively, then B: Call a function that changes the css background image of your div (through an ID) by changing the background image's source.

        
        
    • Image 1
    • Image 2
    • Image 3
    • Image 4

    Note: Your post was in CSS, but you tagged javascript, so I assumed you were open to JavaScript.

提交回复
热议问题