freeCodeCamp Challenge Guide: Change Text Inside an Element Using jQuery

freeCodeCamp Challenge Guide: Change Text Inside an Element Using jQuery
0

Change Text Inside an Element Using jQuery


Solutions

Solution 1 (Click to Show/Hide)
<script>
  $(document).ready(function() {
    $("#target1").css('color', 'red');
    $("#target4").html('<em>#target4</em>');
  });
</script>

<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>

Relevant Links

jQuery API Documentation

freeCodeCamp Guide

3 Likes

$("#target4").html(button id=“target4”);

Why is this telling me I’m missing a ) after argument list. Where would I put another )
?

1 Like

Here is the answer:
$("#target4").html("#target4");

remember about < em > < / em > in the second part

8 Likes

$("#target4").html("#target4");

dont forget to add tags

1 Like

if you don’t mind i asking where shall we put those tags can anyone show us the proper code

2 Likes

what is the right code

GOT THE RIGHT CODE!!!
$("#target4").html("#target4");

1 Like
$("#target4").html("<em>#target4</em>");
14 Likes

Here is the correct answer

18 Likes

Thank you for the answer!
If you can, can you please further explain the < em > tags and how I would use them later down the road? Thank you.

2 Likes

remove all spaces inside the function .html() and it will work

it does not work :frowning:

Here is the answer! $("#target4").html("#target4");