freeCodeCamp Challenge Guide: Give Each Element a Unique id

Give Each Element a Unique id


Solutions

Solution 1 (Click to Show/Hide)
<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"></button>
        <button class="btn btn-default target" id="target2"></button>
        <button class="btn btn-default target" id="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"></button>
        <button class="btn btn-default target" id="target5"></button>
        <button class="btn btn-default target" id="target6"></button>
      </div>
    </div>
  </div>
</div>

this question is a little old but i’m the code should look like this

<button id=“target1” class=“btn btn-default target”>


3 Likes

I did as mentioned above and its not running. I tried running it with id in the front also but nothing, what am I doing wrong?

  <div class="well" id="left-well">
    <button id="Target1" class="btn btn-default target" ></button>
    <button id="Target2" class="btn btn-default target" ></button>
    <button id="Target3" class="btn btn-default target" ></button>
  </div>
</div>
<div class="col-xs-6">
  <h4>#right-well</h4>
  <div class="well" id="right-well">
    <button id="Target4" class="btn btn-default target" ></button>
    <button id="Target5" class="btn btn-default target"></button>
    <button id="Target6" class="btn btn-default target" ></button>
  </div>
</div>
1 Like

You should use id=“target1” AFTER target (think about it)

E.g
button class=“btn btn-default target” id=“target1”></button

2 Likes

tried it, still not working

this is spoiler !!!

<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"></button>
        <button class="btn btn-default target" id="target2"></button>
        <button class="btn btn-default target" id="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"></button>
        <button class="btn btn-default target" id="target5"></button>
        <button class="btn btn-default target" id="target6"></button>
      </div>
    </div>
  </div>
</div>
4 Likes