Streaming live at 10am (PST)

Switching classes on click via code

Hi,

i am really new to the webdesign game and i hope you can help me with this particular problem:
(Read-Only link: Webflow - Bethmanns)

I followed Timothy Ricks´ steps for creating a svg map (Section7).

Now i want to write a code for a class switch. My svg path has a class assigned “WHG” which has a certain style. Then i created a button (class “Wohnungstyp1”).

Now i want to be able to switch the svg-class “WHG” to another class “WHG0” by clicking on the button “Wohnungstyp1”.

I tried this:

$(’.Wohnungstyp1’).click(function() {
$(’.map_whg’).siblings(’.map_embed’).removeClass(‘WHG’);
$(’.map_whg’).siblings(’.map_embed’).addClass(‘WHG0’);
});

and i tried a jillion others…

Please help someone.

Have a nice day,

Yaz

Class names should be lowercase sine Webflow changes them so on publish which you can inspect With your browser

Hi Jeff,

thank you a jillion times. That fixed all my issues.:slight_smile:

BG

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.