Home › Forums › JavaScript › .addClass()/.removeClass() not working as expected.
- This topic is empty.
-
AuthorPosts
-
December 19, 2013 at 11:37 am #158777DamiParticipant
From what I can tell, these methods are exactly what I’m looking for.
What I’m trying to do is have a set of buttons change based on the value selected in a radio group. I’ve tried .hide() and .show(), but they’re not working either. (By “not working” I mean nothing happens. The coded changes aren’t applied.)
http://codepen.io/anon/pen/zvscr Here is my current code. What am I doing wrong? This probably doesn’t need to be said, but jquery/javascript are not my strong suits. :(
Any insights are appreciated. TIA
December 19, 2013 at 11:58 am #158778__Participantcouple things:
in a Codepen, you don’t use
<script>
tags inside the js box. If you look at your console, you’ll see a syntax error:Syntax Error: Unexpected token <
After you fix that, you’ll see this error:
Reference error: $ is not defined
You don’t have jQuery on your page. Remember, it’s a library, not part of the javascript core.
December 19, 2013 at 12:32 pm #158783DamiParticipantThank you for the tips on using Codepen, I appreciate that. :)
I see it’s working with your changes, but it sure as heck isn’t working on my page. :( At least your changes shows me it’s probably not the code, but something else that’s interfering (though the codepen code was cut and pasted from the page’s view source).
Many thanks!! :)
December 19, 2013 at 12:38 pm #158785__ParticipantYou’re welcome.
I see it’s working with your changes, but it sure as heck isn’t working on my page.
Could you share a link to your page?
Did you make sure to add the jQuery script?
December 19, 2013 at 12:47 pm #158786DamiParticipantI would love to, but it’s under password protection. :( Thanks.
Yes, the link to jquery is included on the page.
December 19, 2013 at 1:20 pm #158788__ParticipantYes, the link to jquery is included on the page.
before you try to use
$
? Do you have some other var or library that tries to use$
on the same page? Try (if you’re in chrome, for example)console.log($)
.December 20, 2013 at 4:12 pm #158883DamiParticipantThanks, traq, I got it working. There was another error on the page that was interfering with the jquery script.
Appreciate the help.
-
AuthorPosts
- The forum ‘JavaScript’ is closed to new topics and replies.