title: How to remove element using jQuery()
body: <p>I am trying to add an element when a checkbox is check and remove that same element when a user unchecks the box.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>$(document).ready(function() {
  
        var increment = 0;
        var artist_to_compare = new Set();
  
        $(document).on("change", ".checkbox", function() {
            increment += this.checked ? 1 : -1;
  
            if (!this.checked) {
  
                // // delete the artist from the list of comparison
                $(element_to_delete).remove();
                artist_to_compare.delete(this.name);
                var element_to_delete = "." + this.name;
                console.log(element_to_delete);
  
            } else {
  
                // Add the artist to the list of comparison
                artist_to_compare.add(this.name);
                var element_to_add = '&lt;p class="' + this.name + '"&gt;' + this.name + '&lt;/p&gt;';
                console.log(element_to_add);
                $(".artistToCompare").after(element_to_add);
  
            }
  
            if (increment &gt;= 2) {
                console.log(artist_to_compare);
                // enable the compare button
  
            }
        });
    });
  </code></pre>
  
  <p>I am able to correctly add the element but I cannot remove it. Please help!</p>