I make an AJAX call to a PHP file, and then create formatted HTML if the data was successfully retrieved.
//Function called after AJAX success
function createHTML(data) {
    for( var i = 0; i <= data.length; i++) {
        var label = $("<label>").addClass("checkbox-inline");
        var input = $("<input>").attr("type", "checkbox");
        input.attr("name", "date[]");
        input.attr("class", "date");
        input.attr("value", data[0]['date']);
        label.append(input);
        label.append("data[0]['date']");
        $(".checkboxes").append(label);
        $(".checkboxes").append("<br />");
    }
}
The resulting HTML will look something like this:
 <div class="checkboxes">
    <label class="checkbox-inline">
        <input type="checkbox" name="date[]" class="date" value="2018-01- 
        01">2018-01-01
    </label>
    <br />
    <label class="checkbox-inline">
        <input type="checkbox" name="date[]" class="date" value="2018-01- 
        02">2018-01-02
    </label>
    <br />
  </div>
What I want to do is grab the value of one of the newly created check boxes once it's clicked, but whenever I try to do it nothing happens.
This is what I'm trying to call:
$(".date").on("click", function(){
    console.log(this.value);
});
Is it because the HTML is created after an AJAX call that you can't use an "on click" event?

 
     
     
     
    