0
Can anyone help me debug this
Can anyone help me debug this? I just can't find the error. https://sololearn.com/compiler-playground/Wh8Go41z0HWA/?ref=app
10 Réponses
+ 6
to use a non standard font, you have to import it.
it's also more flexible to use classes rather than modifying the style directly
https://sololearn.com/compiler-playground/WEiPKWwN7MwR/?ref=app
+ 5
Bob_LiAssuming I'm new to coding.
What are classes?
How does this line work?
btn.textContent = btn.textContent=="Click to style" ? "Remove style" : "Click to style";
+ 5
Chris Coder , you're right. we all have to start from simpler concepts, and I really should have commented the code properly. also my preference for short codes often have me typing out ternary expressions all the time... 😅
as for learning what classes are, that's what Sololearn html/css courses are for.
but it's basically style groupings that can be applied to html elements. the OP was applying javascript so I assumed that css was already understood.
the ternary expression:
btn.textContent = btn.textContent=="Click to style" ? "Remove style" : "Click to style";
is a shorthand for:
if(btn.textContent=="Click to style) {
btn.textContent = "Remove style";
} else {
btn.textContent = "Click to style";
}
so that the button text will change when the button is clicked.
ok here's a more basic version with no class toggling. it's more verbose, but it basically does the same thing.
https://sololearn.com/compiler-playground/WOkf4YSfa76o/?ref=app
+ 2
Whats the problem?
+ 1
Your code is working fine
0
Chris Coder okay thx
0
I'm not sure how to troubleshoot this, but I may know of a website that publishes articles on many subjects that could be useful to you in your search, so perhaps you should check it out!
https://www.amazonbookpublisher.co.uk/