question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Waypoint: Target the same element with multiple jQuery Selectors BUG

See original GitHub issue

Challenge Waypoint: Target the same element with multiple jQuery Selectors has an issue. User Agent is: Mozilla/5.0 (Windows NT 6.1; rv:39.0) Gecko/20100101 Firefox/39.0. Please describe how to reproduce this issue, and include links to screenshots if possible.

My code:

<script>
  $(document).ready(function() {
    $("button").addClass("animated shake");
    $(".btn").addClass("animated shake");
    $("#target1").addClass("animated shake btn-primary");


  });
</script>

<!-- You shouldn't need to modify code below this line -->

<div class="container-fluid">
  <h3 class="text-primary text-center">jQuery Playground</h3>
  <div class="row">
    <div class="col-xs-6">
      <h4>#left-well</h4>
      <div class="well" id="left-well">
        <button class="btn btn-default target" id="target1">#target1</button>
        <button class="btn btn-default target" id="target2">#target2</button>
        <button class="btn btn-default target" id="target3">#target3</button>
      </div>
    </div>
    <div class="col-xs-6">
      <h4>#right-well</h4>
      <div class="well" id="right-well">
        <button class="btn btn-default target" id="target4">#target4</button>
        <button class="btn btn-default target" id="target5">#target5</button>
        <button class="btn btn-default target" id="target6">#target6</button>
      </div>
    </div>
  </div>
</div>

Your #target1 element should have the classes animated‚ shake and btn-primary. The error is marked down that my code doesn’t have the right classes. Wich is in this case they are right. I asked on Gitter and I need to do all of them instead of only #target1. Just let you guys know this 😉

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:34 (5 by maintainers)

github_iconTop GitHub Comments

17reactions
ltegmancommented, Oct 15, 2015

The correct answer is actually something like

$(document).ready(function() {
    $("button").addClass("animated");
    $(".btn").addClass("shake");
    $("#target1").addClass("btn-primary");


  });

The goal of the lesson is to show a student how all the specified selectors will have an effect on #target1 even if only one of them is looking for it specifically. Looking at the tests for this challenge again I notice that the tests are actually too permissive. The test Only add one class with each of your three selectors. will pass as long as you call addClass three times, even if each call is adding more than one class.

I’m reopening this bug if someone wants to fix that test and potentially reword the instructions, since I do feel like the explanation of what is expected of the student is not entirely clear.

Thanks again for your report!

5reactions
wiki7commented, Jan 29, 2017

First of all read Question carefully. Question “Only add one class with each of your three selectors.” mean’n-> firstly add individually addClass to your each three selector ( like button, .btn, and btn-primary ) after that add one more addClass for “#target” and in the addClass add your all three selector in the sequence as question want EX- code is… or like this removed solution by mod

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dynamically target multiple HTML elements from one ...
I've long been using the excellent JS plugin called Waypoints.js to change CSS classes based on a user's ...
Read more >
Target the Same Element with Multiple jQuery Selectors ...
Target the Same Element with Multiple jQuery Selectors Solutions Solution 1 (Click to Show/Hide) <script> $(document).ready(function() ...
Read more >
Waypoint: Target the same element with multiple jQuery Selectors
Waypoint : Target the same element with multiple jQuery Selectors. Now you know three ways of targeting elements: by type: $("button"), by class:...
Read more >
Target the Same Element with Multiple jQuery Selectors
In this jQuery tutorial we target the same element with multiple jQuery selectors. This video constitutes one part of many where I cover...
Read more >
List of things broken in the Challenge Map : r/FreeCodeCamp
Waypoint : Target the same element with multiple jQuery Selectors ... Edit: It must be a browser issue, as u/SaintPeter74 pointed out.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found