Guest User

freeCodeCamp Challenge Guide: Target the same element with

a guest
Jan 22nd, 2018
65
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. I found the reason my code wasn't passing and I wonder if it's the same for anyone else? I didn't realize it before but I don't think jQuery wants a dot before class names when they are in the addClass(""); function. When the class is being selected, yes, you use a dot in front of the class name - when you specify the class to be added you do not place a dot in front of it.
  2.  
  3. Below is a copy / paste of the camperbot code from the top of this thread:
  4.  
  5. <script>
  6. $(document).ready(function() {
  7. $("button").addClass("animated");
  8. $(".btn").addClass("shake");
  9. $("#target1").addClass("btn-primary");
  10. });
  11. </script>
  12.  
  13. And this was the code I had before:
  14.  
  15. <script>
  16. $(document).ready(function() {
  17. $("button").addClass("animated");
  18. $(".btn").addClass("shake");
  19. $("#target1").addClass(".btn-primary");
  20. });
  21. </script>
  22.  
  23. See the difference?
  24.  
  25. That was my problem. It could be yours too?
  26.  
  27. HTH
RAW Paste Data