[Help] Javascript code help needed

Tpati

Registered Member
Joined
Sep 12, 2015
Messages
92
Reaction score
43
I want to know how can I hide a certain class when another class is active,
The concept is surely clear but I am unable to code it.
So what I want to do basically is :
when class XYZ is active I want to hide class ABC.
oblige :)
 
document.getElementsByClassName returns a Collection of all the elements matching the class name.


You can access the element you want using the bracket with the index or subscript notation.


document.getElementsByClassName('appBanner')[0].style.visibility='hidden';
Hope it helps!
 
Hi OP, I quickly wrote this as something basic to start off with: http://plnkr.co/edit/8riKUcAl2A1AazP2aYSl?p=preview

basically, you'll see the script checking for a class (this will be your active class), if it finds it, it will change the class (here you can add whatever other class) of whatever element you want. Hope it makes sense :)
 
Thread moved to the proper section.
 
Use jQuery add/remove method.
$('element').addClass('show').removeClass('hide');
 
Back
Top