22

Part of my code wasn't working until I changed my class into an id... How was using a class incorrect??

Comments
  • 3
    Do you have gists for both available? Then I might be able to tell you what happened. Until then it's to less information to say anything.
  • 1
    Maybe that tag is an anarchist.
  • 0
    @plusgut
    It's not on github if that's what you're talking about. This happens all the time. At this point, I'm convinced classes simply hate me.
  • 1
    @Michelle hm okay, without any code, I can't help you.
  • 1
    @Michelle Are you sure your code works on all elements with same class and not just one? (Hence why it might work if you do it by id instead.) Did you try step through debugging?
  • 0
    @k0pernikus
    There was only one element for that class.
  • 0
    Part of which code didn't work? I mean PHP JavaScript CSS?
  • 1
    @lucifyer
    It's a bit obvious, considering the fact I said I changed the class to an id. I'm not sure why everyone is trying to help. I wasn't asking a question lol.
  • 1
    I assume your referring to css

    The main difference between a class and an id is that an id has to be unique.

    And you use different ways to get the element/elements they represent.

    When using a class you could get multiple matches but with an id you will only get one.

    Could any of that be a clue?
  • 1
    @Voxera
    I know the difference between a class and id. I've been doing this for 3-4 years, it's nothing new to me.
  • 0
    @everyone
    I'm not asking a question haha. Stahp trying to help. However, I appreciate your efforts.
  • 1
    @Michelle how about posting the code which was not working? Then we can exactly tell you what went wrong.
  • 1
    @Michelle So you don't want to improve and learn something?
  • 1
    you know it was friday the 13th๐Ÿ˜‚
  • 2
    @jakobev
    OH MY GOODNESS.
    THAT'S RIGHT!
    No wonder nothing is working for me today ;)
  • 1
    @matsaki95 for me also a normal day xD
  • 2
    I'm probably wrong, but this sounds like a CSS specificity issue.
    You can use this to test it: specificity.keegan.st
  • 1
    @shellbug
    I'll try it out, thanks :)
  • 1
    @Michelle maybe you just post the code and we can help you out

    .

    ...just kidding

    But I would actually be interested why it would work with an id instead of a class. Maybe because in js you get an array returned?
Add Comment