change only the color of the button clicked and the others return to the original color VueJS

I have 3 buttons, when I click on one of them, the other two would like them to go back to the original color

my html

       <div class="col-md-8 row gutter-sm opts">
          <q-btn 
            id='1'
            class="col-md-2 opt"
            label="OPTIONS 1"
            style="color: white"
            @click="filters(1);"
          />
          <q-btn 
            id='2'
            class="col-md-2 opt"
            label="OPTIONS 2"
            style="color: white"
            @click="filters(2);"
          />
          <q-btn 
            id='3'
            class="col-md-2 opt"
            label="OPTIONS 3"
            style="color: white"
            @click="filters(3);"
          />
       </div>

my JS

   methods: {
      filters(id){
         var select = id
         document.getElementsByClassName("opt").style.backgroundColor="white"
         document.getElementById(select).style.backgroundColor='black'
      }
   }

71 thoughts on “change only the color of the button clicked and the others return to the original color VueJS”

  1. Can I simply say what a relief to uncover someone who really understands
    what they’re talking about on the web. You certainly realize how to bring a problem to light and make it important.
    More people ought to check this out and understand this side of the
    story. I can’t believe you aren’t more popular since you definitely possess the gift.

    Reply
  2. I don’t know if it’s just me or if everybody
    else experiencing problems with your blog. It appears like some of the text in your content are running off the screen. Can somebody else please comment and let
    me know if this is happening to them too? This could be a problem
    with my internet browser because I’ve had this
    happen before. Kudos

    Reply
  3. Excellent goods from you, man. I have understand your
    stuff previous to and you’re just too wonderful.
    I really like what you have acquired here, really
    like what you are saying and the way in which you say it.
    You make it enjoyable and you still care for to keep it sensible.
    I can’t wait to read far more from you. This is actually a tremendous website.

    Reply
  4. I’m extremely impressed with your writing
    skills and also with the layout on your weblog.
    Is this a paid theme or did you customize it yourself?
    Either way keep up the nice quality writing, it’s rare to see a great blog like
    this one nowadays.

    Reply
  5. Hi, I do think this is a great website. I stumbledupon it 😉 I am going to come back yet again since i have saved as
    a favorite it. Money and freedom is the best way to change, may
    you be rich and continue to guide other people.

    Reply
  6. Thanks for another informative website. The place else could I am getting that type of information written in such
    an ideal way? I’ve a venture that I’m just now operating on, and
    I have been at the look out for such info.

    Reply
  7. I used to be suggested this web site through my
    cousin. I’m now not positive whether or not this put up
    is written via him as no one else understand such
    distinct about my problem. You are incredible! Thanks!

    Reply
  8. I think this is one of the so much significant information for me.
    And i’m happy reading your article. However should commentary on few general issues,
    The site taste is ideal, the articles is in point of fact excellent : D.
    Just right job, cheers

    Reply
  9. Oh my goodness! Amazing article dude! Many thanks, However I am going through problems with
    your RSS. I don’t know the reason why I can’t join it. Is there anybody else having the same RSS
    issues? Anybody who knows the answer can you kindly respond?
    Thanks!!

    Reply
  10. Hello There. I found your weblog using msn. This is a very neatly written article.
    I will make sure to bookmark it and come back to read extra of your useful information. Thanks
    for the post. I’ll definitely return.

    Reply
  11. I’m not sure where you’re getting your info, but great topic.
    I needs to spend some time learning more or understanding more.
    Thanks for wonderful information I was looking for this information for my mission.

    Reply
  12. Pretty great post. I just stumbled upon your weblog and wished to mention that I have truly enjoyed surfing around your weblog posts.
    In any case I’ll be subscribing in your rss feed and I am hoping you write again soon!

    Reply
  13. Greetings from Ohio! I’m bored to death at work so I
    decided to check out your website on my iphone during lunch break.

    I really like the info you present here and can’t wait to take a look when I get home.
    I’m amazed at how quick your blog loaded on my phone .. I’m not even using WIFI, just 3G ..

    Anyways, very good site!

    Reply
  14. Unquestionably believe that which you said.
    Your favorite reason seemed to be on the web the simplest
    thing to be aware of. I say to you, I definitely get annoyed while people consider worries that they
    plainly do not know about. You managed to
    hit the nail upon the top and defined out the whole thing without having side-effects , people
    can take a signal. Will probably be back to get more.
    Thanks

    Reply
  15. It is appropriate time to make some plans for the future and it’s time to be happy.

    I have read this post and if I could I desire to suggest you few interesting things or tips.

    Perhaps you can write next articles referring to this article.
    I desire to read even more things about it!

    Reply
  16. Hello would you mind stating which blog platform you’re using?
    I’m planning to start my own blog soon but I’m
    having a difficult time making a decision between BlogEngine/Wordpress/B2evolution and Drupal.
    The reason I ask is because your layout seems different then most blogs and I’m looking for something completely unique.
    P.S Apologies for getting off-topic but I had to ask!

    Reply
  17. I have been exploring for a bit for any high quality articles or blog posts in this kind of house .
    Exploring in Yahoo I finally stumbled upon this web site.

    Studying this information So i am happy to express that I’ve a
    very good uncanny feeling I found out exactly what I needed.
    I so much undoubtedly will make certain to do not put
    out of your mind this web site and provides it a glance on a continuing basis.

    Reply
  18. I know this if off topic but I’m looking into starting my own weblog
    and was curious what all is needed to get set
    up? I’m assuming having a blog like yours would cost a pretty penny?
    I’m not very web smart so I’m not 100% positive. Any suggestions or advice would be greatly appreciated.
    Kudos

    Reply
  19. Hi, I do believe this is an excellent website. I stumbledupon it 😉 I’m going
    to return once again since I book-marked it.

    Money and freedom is the greatest way to change, may you be rich and continue to
    help others.

    Reply
  20. When I initially commented I clicked the “Notify me when new comments are added” checkbox and now each time a comment is added I get four emails with the same comment.
    Is there any way you can remove me from that service?

    Thanks a lot!

    Reply

Leave a Comment