JavaScript How can I specifically target and apply a function to individual images from a GET requested JSON file?

My question has two parts here: I have created an Instagram clone and would like to be able to click on each individual image and have a like feature. The way that I currently have this set up is by clicking on an image, it would just change the color of the fa-heart class from grey to red. This works fine, but I would like to target each img / <div> individually. I am pulling all of my images in via a JSON file, the problem is when clicking on one photo all of the hearts change. How can I specifically target each item individually with this functionality?

Here is the jsbin: http://jsbin.com/tecaha/edit?output

And here is the code:

HTML

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
  <link rel="stylesheet" target='_blank' href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
</head>
  <body>

    <header>
      <div class="top">     

        <ul>
          <li><i class="fa fa-home fa-2x"></i>
          </li>
          <li id="logo">
            <img src="http://i.imgur.com/SmdPZ6T.png" />
          </li>
          <li id="profile-photo">
            <img src="https://scontent-sea1-1.cdninstagram.com/hphotos-xaf1/t51.2885-19/10731946_1517235648523785_1216221661_a.jpg" />
            <p class="username">username</p>
          </li>
        </ul>
      </div>
    </header>
    <div id="container">
      <main>
        <div id="feed-container">
            <ul id="images">

            </ul>
          </div>
          <ul class="comment-list">

          </ul>
      </main>
      </div>
  </body>
</html>

CSS

* {
  margin: 0px;
  padding: 0px;
}
body {
  font-family: "proxima-nova", "Helvetica Neue", Arial, Helvetica, sans-serif;
}
ul {
  list-style: none;
}
li {
  list-style: none;
}
#container {
  margin: 0 auto;
  display: block;
}
header {
  margin: 0 auto;
  display: block;
  background-color: #3E6D93;
  height: 50px;
}
.top {
  background: #467ea6;
  background: -webkit-gradient(linear, 0 0, 0 100%, color-stop(0.01, #467ea6), to(#27608c));
  background: -webkit-linear-gradient(#467ea6 1%, #27608c 100%);
  background: -moz-linear-gradient(#467ea6 1%, #27608c 100%);
  background: -o-linear-gradient(#467ea6 1%, #27608c 100%);
  background: linear-gradient(#467ea6 1%, #27608c 100%);
  filter: progid: DXImageTransform.Microsoft.gradient( startColorstr='#467ea6', endColorstr='#27608c', GradientType=0);
  width: 100%;
}
.top li {
  display: inline-block;
  margin: 0 auto;
}
#home-button, .fa-home {
  float: left;
  background-color: #305F87;
  color: #ccc;
  padding: 7px;
  margin-left: 200px;
  width: 35px;
}
.fa-home {
  padding-left: 12px;
}
#logo img {
  float: right;
  width: 110px;
  margin-left: 400px;
  padding: 6px;
}
#profile-photo  {
  float: right;
  margin-right: 200px;
  padding: 10px;
  border-left: 1px solid #305F87;
  border-right: 1px solid #305F87;
  width: auto;
}
#profile-photo img  {
  width: 30px;
  height: 30px;
  border-radius: 5px;
}
#profile-photo p {
  color: #fff;
  font-weight: bold;
  font-size: 14px;
  text-align: center;
  float: right;
  margin-left: 10px;
  padding: 5px;

}
#feed-container {
  background-color: #DFDFDF;
  width: 650px;
  height: auto;
  margin: 0 auto;
  display: block;
}
#images {
  margin: 0 auto;
  display: block;
  padding-top: 50px;
  padding-bottom: 30px;
}
#images img {
  margin: 0 auto;
  display: block;
  width: 550px;
  height: 550px;
}
.below-image {
  margin: 0 auto;
  display: block;
  width: 550px;
  height: 52px;
  background-color: #fff;
  border: 1px solid #ccc;
}
.like {
  float: left;
}
.fa-heart {
  color: #5a5a5a;
  padding: 10px;
  border-right: 1px solid #ccc;
}
.liked {
  color: #ff0000;
}
.image-info {
  float: left;
  text-align: left;
  width: 437px;
  height: 52px;
  border-right: 1px solid #ccc;
}
.image-info p {
  color: #467ea6;
  font-weight: bold;
  padding-top: 15px;
  padding-left: 20px;
  float: left;
}
.more {
  float: right;
  color: #5a5a5a;
}
.more, .info {
  display: inline-block;
  font-size: 45px;
  color: #5a5a5a;
  padding: 0 5px;
  background-color: transparent;
  border: 0;
  cursor: pointer;
  outline: none;
}
#clear {
  clear: both;
}
.comment-container {
  width: 550px;
  height: 200px;
  margin-bottom: 50px;
}

#add-a-comment {
  margin: 0 auto;
  display: block;
  background-color: #fff;
  width: 550px;
  height: auto;
  margin-bottom: 50px;
}
#add-a-comment p {
  margin: 0 auto;
  display: block;
}
#add-a-comment input[type=text] {
  width: 450px;
  border: 1px solid #ccc;
  color: #4f4f4f;
  font-size: 16px;
  border: 0;
  bottom: 40px;
  padding: 15px;
  outline: none;
}
input, select, textarea{
  color: #f00;
}
.inserted {
  cursor: pointer;
}
/*#addNewComment {
  font-size: 16px;
  border: 0;
  bottom: 40px;
  padding: 15px;
  outline: none;
  width: 100px;
}*/

JavaScript/jQuery

// Variable of html strings
var bottom = '<div class="below-image">' +
    '<div class="like">' +
    '<i class="fa fa-heart fa-2x"></i>' +
    '</div>' +
    '<div class="image-info">' +
    '<p>User Info</p>' +
    '</div>' +
    '<div class="more">' +
    '<button class="info">ยทยทยท</button>' +
    '</div>' +
    '<div id="clear"></div>' +
    '</div>' +
    '<div id="add-a-comment">' +
    '<div class="comment-container">' +
    '<form class="comment" action="index.html" method="post">' +
    '<input id="enter" type="text" name="newcomment" value="" placeholder="Add a comment...">' +
    '</form>' +
    '</div>' +
    '</div>' +
    '</li>';


// GET Request to grab the data from the JSON file
$(document).ready(function () {
    var jsonURL = "https://codesmith-precourse.firebaseio.com/instagram/-JqL35o8u6t3dTQaFXSV.json";
    $.getJSON(jsonURL, function (json) {
        var imgList = "";
    //var newImage = "http://yourbizrules.com/wp-content/uploads/2014/08/Staying-Motivated.jpg";

    $.each(json, function (i) {
            imgList += '<li><img class="inserted" src= " ' + json[i] + ' ">' + bottom;
        });
        $('#images').append(imgList);
    });
});

// Like Photos

// $(document).ready(function() {
//   $(".inserted").on('click', '.inserted', function() {
//     $(".fa-heart").toggleClass(".liked");
//   });
// });


$(document).ready(function() {
    $('#images').dblclick(function() {
    $('.fa-heart').addClass('liked');
    });
});
Answer:1

How can I localize current day and month (without year) in moment.js? What I want is exactly the output of moment().format('LL') but without the year part. Consider the following example: moment()....

How can I localize current day and month (without year) in moment.js? What I want is exactly the output of moment().format('LL') but without the year part. Consider the following example: moment()....

I have been working on a function that loops through a JSON object recursively, and want to use each key it finds as the class value of an element to change the .text value of that element in jQuery. ...

I have been working on a function that loops through a JSON object recursively, and want to use each key it finds as the class value of an element to change the .text value of that element in jQuery. ...

  1. join array values javascript
  2. join array values python
  3. join array values c#
  4. join array values powershell
  5. join array values php
  6. join array values
  7. join array values jquery
  8. join array values java
  9. join array values js
  10. twig join array values
  11. php join array values into string
  12. javascript join array values to string
  13. typescript join array values
  14. postgresql join array values
  15. postgres join array values
  16. bash join array values
  17. join two array values in php
  18. vba join array values
  19. powershell join array values to string
  20. perl join array values

Is there an elegant way (without a for loop) to create a sequential array in Javascript which starts from a certain number and has a certain numbers of items. for example: Start from 2017 and has 4 ...

Is there an elegant way (without a for loop) to create a sequential array in Javascript which starts from a certain number and has a certain numbers of items. for example: Start from 2017 and has 4 ...

I know to find a value exist or not in an array I can use indexOf, but how to do it with an array of object? const x = [{ "id": "roadshows", "name": "Roadshows" }, { "id": "sporting_events", "...

I know to find a value exist or not in an array I can use indexOf, but how to do it with an array of object? const x = [{ "id": "roadshows", "name": "Roadshows" }, { "id": "sporting_events", "...

  1. indexof array object javascript
  2. indexof array object typescript
  3. indexof array object
  4. indexof array object js
  5. indexof array object jquery
  6. indexof(array object) c#
  7. index of array object property
  8. array indexof object property
  9. array indexof object not working
  10. array indexof object key
  11. array indexof object value
  12. array indexof object swift
  13. indexof object array angularjs
  14. indexof object array java
  15. index of object array swift 4
  16. javascript indexof array object property
  17. get index of array object javascript
  18. find index of array object javascript
  19. get index of array object