here is a script that would do what you asked ... just replace the one in the video with this one... add a few more buttons and see what happens... document.querySelectorAll(".pill").forEach((pill) => { pill.addEventListener("click", () => { document.querySelectorAll(".pill--selected").forEach((p) => { p.classList.remove("pill--selected"); }); pill.classList.add("pill--selected"); }); });
ok bro nice but it will be more helpful if u do a video about algorithms step by step and teach us how we solve a problem I'm done with HTML and CSS so please if u can thx
@dcode... this is a better script ... it unselects previously selected buttons and selects the clicked one document.querySelectorAll(".pill").forEach((pill) => { pill.addEventListener("click", () => { document.querySelectorAll(".pill--selected").forEach((p) => { p.classList.remove("pill--selected"); }); pill.classList.add("pill--selected"); }); });
That’s so easy… when you know!! Fantastic lesson!! Thank you 🙏
Wow, I was expecting more complicated ways of doing it and the video ends! I am amazed by how easy it was to do these. Thank you for sharing.
Very nice and easy explanation, thanks.
Thank you Brother ,Its Really Help full for me
2:50 1 em is 16 px btw not 12 px.
Hey what is your visual studio theme and how do you make it so that the letters appears smoothly as you write?
please do more web components tuts !
I used radiobuttons for background color, this way pill--selected has the same background color on reload
i am not sure if you've already done video for that but would you please consider make a tutorial how to create simple tagging system?
here is a script that would do what you asked ... just replace the one in the video with this one... add a few more buttons and see what happens...
document.querySelectorAll(".pill").forEach((pill) => {
pill.addEventListener("click", () => {
document.querySelectorAll(".pill--selected").forEach((p) => {
p.classList.remove("pill--selected");
});
pill.classList.add("pill--selected");
});
});
@@suelingsusu1339 Thank you dude, much appreciated :),
ok bro nice but it will be more helpful if u do a video about algorithms step by step and teach us how we solve a problem I'm done with HTML and CSS so please if u can thx
first view
@dcode... this is a better script ... it unselects previously selected buttons and selects the clicked one
document.querySelectorAll(".pill").forEach((pill) => {
pill.addEventListener("click", () => {
document.querySelectorAll(".pill--selected").forEach((p) => {
p.classList.remove("pill--selected");
});
pill.classList.add("pill--selected");
});
});