javascript - Regarding the radio button problem, I am a novice, I hope someone can help me.
PHP中文网2017-05-24 11:36:42
0
4
693
The company wants to create an event page with 4 buttons. When the button is clicked, it is equivalent to the selected state and the background image is changed.
How to restore the previous one to its original state when clicking the next one.
This editing tool, I guess it may be dw. . . Then this code also reveals a fresh breath. First of all, let me tell you that writing switching is not how you write it. Only a small number of demon cultivators can write this way, and it is informal. We cultivators generally achieve our goals by modifying classes. Simpler way of writing:
First of all, your IMG doesn’t have an ID. Why are you writing this ID here? If you want to use ID control, add the ID first... Then you can make two button styles, one selected and one unselected. Then use js to control when a button is clicked to add the selected style to the button's CSS, and then clear the selected styles of other buttons.
The button image is written into the background-image, and the selected one is added with class to cover the image
This editing tool, I guess it may be dw. . . Then this code also reveals a fresh breath.
First of all, let me tell you that writing switching is not how you write it. Only a small number of demon cultivators can write this way, and it is informal. We cultivators generally achieve our goals by modifying classes.
Simpler way of writing:
At this time, we can achieve the corresponding purpose by operating the "choose" class name through js.
First of all, your IMG doesn’t have an ID. Why are you writing this ID here? If you want to use ID control, add the ID first...
Then you can make two button styles, one selected and one unselected. Then use js to control when a button is clicked to add the selected style to the button's CSS, and then clear the selected styles of other buttons.
css:
javascript: