Skip to content
The Chat Archive
gpt-4-0314· OpenAI WildChat-4.8M (AI2)

<html> <head> <title>Music tracker</title> <meta name=“viewport”…

  1. User

    <meta name=“description” content=“Keep track of your favorite songs and artists with Music Tracker.”>

    <meta name=“keywords” content=“music, tracker, songs, artists, favorites”>

  2. Assistant

    (document).ready(function() { // Add a new song to the music tracker ("#addSong").click(function() { var songTitle = ("#songTitle").val().trim(); var artistName = ("#artistName").val().trim();

    if (songTitle === "" || artistName === "") {
      alert("Please enter both the song title and artist name.");
    } else {
      var newRow = $("<tr>");
      newRow.append($("<td>").text(songTitle));
      newRow.append($("<td>").text(artistName));
    
      var deleteButton = $("<button>").addClass("btn btn-danger btn-delete").text("Delete");
      newRow.append($("<td>").append(deleteButton));
    
      $("#musicList tbody").append(newRow);
    
      $("#songTitle").val("");
      $("#artistName").val("");
    }
    

    });

    // Remove a song from the music tracker (document).on("click", ".btn-delete", function() { (this).closest("tr").remove(); }); });

    <div class="form-group">
      <label for="artistName">Artist Name</label>
      <input type="text" class="form-control" id="artistName" placeholder="Enter artist name">
    </div>
    
    <button type="button" class="btn btn-primary" id="addSong">Add to Music Tracker</button>