I´m trying to "toggle" multiple divs with just 2 buttons (one for SHOW and the other for HIDE ) in relation to the last div showed by the function, with SHOW and HIDE
So, if I click one time (on SHOW), it must display div with class num1. If I click again, div with class num2 until num5. But, if I click on HIDE, it must hide the last div showed. Is this possible?
You could try to do it like this:
Use an index
to store the last class shown.
Everytime you click on the show button increment this index
and then $(".num"+index).show()
this class.
If you click the hide, do $(".num"+index).hide()
and then decrement the index
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.