Basically I have 2 columns, first one being a <ul> and its <li> and the other a bunch of <div> wrapped inside a master <div>.
What I am trying to do is that, when user clicks <li#Apple>, it will add class āunhideā to <div#Apple> and remove āunhideā from all its siblings.
The code works well, but Iām wondering if anyone here could help me improve my code. Iām still learning now, and not really a code guy. But I would love to know how it can be improved.
Due to NDA, I canāt share any links to the site. The code piece is my only option. As you could see the way it was written is very redundant, Iām wondering any possibilities to make it more efficient or shorter.
To me that code is fine, thereās a saying that goes around in Software Development - KISS (Keep it Simple Stupid)
I can see exactly what itās doing, and thereās nothing fancy so no need to bother with improving performance.
Thumbs up dude and good luck with your journey into the programming world!
NOTE: What does āunhideā mean? (rhetorical)
I would rather use a convention that states the classās intention explicity like āshowā or āvisibleā. By saying āunhideā you are using a double negative
NOTE #2: There is a JQuery function called .show() and .hide(), check them out if you can
Iām not sure why you need to use the class āunhideā, if there is no animation involved, you can do away with adding and removing the classes, and use jQuery .show() and .hide()
Wow awesome! @samliew and @Aidz, thanks a bunch guys! The code works, tested all of them. Besides some minor typo. Iāll rename the class as your suggested @Aidz.