JSFiddle - React, Tailwind, and code Playground

by akang2

HTML

<!doctype html>
<html lang="en">
<head>
<title>Webville Tunes</title>
<meta charset="utf-8">
</head>
<body>

<form>
<input type="text" id="songTextInput" size="40" placeholder="Song name">
<input type="button" id="addButton" value="Add Song">
</form>

<ul id="playlist">

</ul>

</body>
</html>

CSS

/* playlist.css */

body {
    font-family: arial, sans-serif;
}

ul#playlist {
    border: 1px solid #a9a9a9;
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 5px;
    margin-top: 10px;
    padding: 0px;
    list-style-type: none;
}

ul#playlist li {
    border-bottom: 1px solid #a9a9a9;
    padding: 10px;
    background-image: -webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#e3e3e3));
    background-image: -moz-linear-gradient(#f9f9f9, #e3e3e3);
    background-image: -ms-linear-gradient(#f9f9f9, #e3e3e3);
    background-image: -o-linear-gradient(#f9f9f9, #e3e3e3);
    background-image: -webkit-linear-gradient(#f9f9f9, #e3e3e3);
    background-image: linear-gradient(#f9f9f9, #e3e3e3);
}

ul#playlist li:last-child {
    -webkit-border-bottom-right-radius: 5px;
    -webkit-border-bottom-left-radius: 5px;
    -moz-border-radius-bottomright: 5px;
    -moz-border-radius-bottomleft: 5px;
    border-bottom: none;
    border-bottom-right-radius: 5px;
    border-bottom-left-radius: 5px;
}
ul#playlist li:first-child {
    -webkit-border-top-right-radius: 5px;
    -webkit-border-top-left-radius: 5px;
    -moz-border-radius-topright: 5px;
    -moz-border-radius-topleft: 5px;
    border-top-right-radius: 5px;
    border-top-left-radius: 5px;
}

JavaScript

//Head First HTML5 Ch 3

window.onload = init;

function init() {
    var button = document.getElementById("addButton");
    button.onclick = handleButtonClick;
}

function handleButtonClick(){
    var getSong = document.getElementById("songTextInput");
    var theSong = getSong.value;         //Why put this in a var? Can't we just use "getSong.value"?
/*    postSong;
}

function postSong(){*/
    var theLi = document.createElement("li");
    theLi.innerHTML = theSong;
    
    var theUl = document.getElementById("playlist");
    //(document.getElementById("playlist")).appendChild(theLi);
    theUl.appendChild(theLi);
}