How do I add class to html elements so that everytime user clicks on it, the border color of the element changes?
For example, in the example codepen I want to set those cards’ border to blue once user clicks on it.
thanks for the help, as you can see I am fairly new when it comes to learning to manipulate the dom, where should I start to learn these?
because right now I am basically googling blindly and just keep guessing what I should do to the element like : “maybe I should add a class to it? how do I select all these??”
Is there a list of most common dom manipulation command I should check out?
I think it’s better if you study something structured first and then you try to clone or build something from scratch.
If you go through https://learn.freecodecamp.org/ by the time you finish the “Front End Libraries Certification” you’ll know exactly how to do it, be it in vanilla, jquery or even react. But you must start from the beginning, learning the DOM and javascript itself first.
After you’ve done that, you’re correct in the way you are programming now. Programmers always google how to do stuff and asks questions, there’s no way anyone can remember every function every time, so don’t feel bad for doing that. What’s missing for you is that “base knowledge”, you must know what to search or ask for.
Learn the DOM and javascript. Javascript can manipulate the DOM just fine nowadays, you don’t need jQuery for that.
thank you ! I actually did the jQuery part a year ago now I just forgot everything…
gonna relearn it later. also I gotta a felling that object oriented programming part is gonna take me a while to truly digest. I am planning to finish all these within this year. when I come back to this project, I will tag you if I have more question. thanks!
@zhouxiang19910319
Hi there. In terms of learning and becoming more comfortable with JS (and jQuery) I would always recommend Traversy Media’s youtube channel as a resource outside of FCC. He has a number of smaller project videos to do with various parts of JS. Following some of his code along’s are a great way of getting use to different areas and seeing them in action. Additionally, you can revisit FCC or use MDN web docs on specific pieces that feel more challenging for you.
I think I knew which videos you are talking about. I did watch his videos about js. Some of them are teaching you how to manipulate the dom by building a form, while others teach you a little bit of javascript algorithms. I just did not follow through the whole thing. I will check those out later. Thanks for the suggestion!
No problem! He has some crash course type videos with more length, but I personally prefer his mini projects, as you can take on small sized projects at your own pace, and focus on more specific stuff, as oppose to a whole general overview of JS (everyone has different learning methods though.) Always good to have several resources to learn from but. Hope the learning goes well!
I agree completely! I love being on the forum. I find myself wanted to help out people that are having issues or getting stuck (even with my limited knowledge.) It forces me to learn more, and strengthen my knowledge on things I already know. Always open to help or offer support where I can! (A little off topic)