HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<div class="container">
<div class="select-record">
<img src="https://i.ibb.co/Nnf216Z/btn-header.png"/></a>
<span class="cta">click to randomize</span>
</div>
<div id="recordinsert">
<!--DIV INSERT FROM JS-->
</div>
</div>
<input type="checkbox" name="toggle" id="toggle" />
<label for="toggle"></label>
<div class="dropdown">
<div class="dropdown-content">
<div class="row genre-head" id="musictype">
<div class="col span-2-of-2 genres">
<ul class="settings">
<li>
<select name="num-records" id="num-records">
<option value="1">1 Record</option>
<option value="2">2 Records</option>
<option value="3" selected>3 Records</option>
<option value="4">4 Records</option>
<option value="5">5 Records</option>
</select>
</li>
<li>
<input id="chkAll" type="checkbox" checked/>
<label for="chkAll"></label>
</li>
</ul>
</div>
<div class="row genre-options">
<div class="col span-1-of-2 genres">
<ul>
<li>
<input id="chkProg" class="gchk" type="checkbox" name="genre" value="4" checked/>
<label for="chkProg">Prog</label>
</li>
<li>
<input id="chk70" class="gchk" type="checkbox" name="genre" value="6" checked/>
<label for="chk70">70's</label>
</li>
<li>
<input id="chk60" class="gchk" type="checkbox" name="genre" value="7" checked/>
<label for="chk60">60's</label>
</li>
<li>
<input id="chkElectro" class="gchk" type="checkbox" name="genre" value="8" checked/>
<label for="chkElectro">Electro</label>
</li>
<li>
<input id="chkHipster" class="gchk" type="checkbox" name="genre" value="9" checked/>
<label for="chkHipster">Alternative</label>
</li>
<li>
<input id="chkMetal" class="gchk" type="checkbox" name="genre" value="10" checked/>
<label for="chkMetal">Metal</label>
</li>
</ul>
</div>
<div class="col span-1-of-2 genres">
<ul>
<li>
<input id="chkRap" class="gchk" type="checkbox" name="genre" value="1" checked/>
<label for="chkRap">Rap</label>
</li>
<li>
<input id="chkRB" class="gchk" type="checkbox" name="genre" value="2" checked/>
<label for="chkRB">R & B</label>
</li>
<li>
<input id="chkFunk" class="gchk" type="checkbox" name="genre" value="3" checked/>
<label for="chkFunk">Funk</label>
</li>
<li>
<input id="chkReggae" class="gchk" type="checkbox" name="genre" value="11" checked/>
<label for="chkReggae">Reggae</label>
</li>
<li>
<input id="chkPop" class="gchk" type="checkbox" name="genre" value="5" checked />
<label for="chkPop">Pop</label>
</li>
<li>
<input id="chkMisc" class="gchk" type="checkbox" name="genre" value="12" checked/>
<label for="chkMisc">Misc</label>
</li>
</ul>
</div>
</div>
/* -------------------------------- */
/* BASIC SETUP */
/* -------------------------------- */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
color: #fff;
font-family: "helvetica", "Arial", sans-serif;
font-size: 20px;
text-rendering: optimizeLegibility;
}
body {
background-color: #666666;
height: 100vh;
display: flex;
overflow: hidden;
}
h2 {
font-size: 100%;
font-weight: 400;
margin-bottom: 4px;
color: white;
}
h3 {
font-size: 70%;
font-weight: 100;
text-transform: uppercase;
color: #ccc;
letter-spacing: 1px;
}
.cta{
font-size:12px;
text-transform:uppercase;
display:flex;
justify-content:center;
opacity:.5;
}
/* -------------------------------- */
/* Top */
/* -------------------------------- */
.container {
width: 85%;
margin: auto;
cursor:pointer;
transition: all 150ms ease;
}
@media only screen and (max-width: 600px) {
.container{
margin:53% auto;}
}
.select-record img {
display: block;
width: 100%;
max-width: 400px;
margin-bottom: 16px;
margin-left: auto;
margin-right: auto;
}
/* -------------------------------- */
/* RECORD DISPLAY */
/* -------------------------------- */
.random-record {
padding: 16px 16px;
width: 100%;
max-width: 400px;
border-bottom: 1px solid #ccc;
text-align: center;
transition: all 500ms ease;
}
.random-record:first-child {
padding-top: 0;
}
.random-record:last-child {
border-bottom: 0px solid #ccc;
}
#recordinsert {
position: absolute;
width:85%;
max-width: 400px;
top: 50%;
left: 50%;
transform: translate(-50%, -55%);
animation: fadeIn 1.75s ease-out;
-webkit-animation: fadeIn 1.75s ease-out;
}
/* -------------------------------- */
/* Animations */
/* -------------------------------- */
@keyframes fadeIn {
0% {
opacity: 0;
}
60% {
opacity: 0;
}
100% {
opacity: 1;
}
}
/* -------------------------------- */
/* FILTER */
/* -------------------------------- */
label {
padding: 32px 0;
}
.genre-head {
padding: 16px;
}
.settings {
padding-bottom: 16px;
border-bottom: 1px solid #ccc;
}
li {
list-style: none;
padding: 16px 0;
text-shadow: 3px 2px 2px rgba(0, 0, 0, 0.5);
}
select {
width: 100%;
max-width: 400px;
}
/* -------------------------------- */
/* dropdown */
/* -------------------------------- */
.dropdown {
background: rgba(52, 52, 52, 0.95);
color: #fff;
position: absolute;
top: 100%;
left: 0;
height: 100%;
width: 100%;
padding: 0 16px;
transition: top 300ms cubic-bezier(0.17, 0.04, 0.03, 0.94);
overflow: hidden;
box-sizing: border-box;
}
#toggle {
position: absolute;
appearance: none;
cursor: pointer;
left: -100%;
top: -100%;
}
#toggle + label {
position: absolute;
bottom: 0;
cursor: pointer;
background: #26ae90;
width:100%;
padding: 8px 10px;
color: #fff;
line-height: 20px;
font-size: 12px;
text-align: center;
-webkit-font-smoothing: antialiased;
cursor: pointer;
transition: all 500ms ease;
z-index: 1;
margin-left: 0;
padding:16px 0;
font-size: 100%;
}
@media only screen and (max-width: 600px) {
#toggle + label{
padding: 16px 0 88px 0;}
}
#toggle + label:after {
content: "Filter";
}
#toggle:checked ~ .dropdown {
top: 0%;
}
#toggle:checked + label {
background: #dd6149;
}
#toggle:checked + label:after {
content: "Close";
}
#chkAll {
position: absolute;
appearance: none;
cursor: pointer;
left: -100%;
top: -100%;
}
#chkAll:checked + label:after {
content: "Remove All Genre";
}
#chkAll + label:after {
content: "Add All Genre";
}
.gchk:checked + label {
opacity: 1;
}
.gchk + label {
opacity: 0.25;
}
.gchk {
position: absolute;
appearance: none;
cursor: pointer;
left: -100%;
top: -100%;
}
/* -------------------------------- */
/* Grid */
/* -------------------------------- */
.row {
zoom: 1; /* For IE 6/7 (trigger hasLayout) */
}
.row:before,
.row:after {
content: "";
display: table;
}
.row:after {
clear: both;
}
/* GRID COLUMN SETUP ==================================================================== */
.col {
display: block;
float: left;
margin: 1% 0 1% 1.6%;
}
.col:first-child {
margin-left: 0;
} /* all browsers except IE6 and lower */
/* GRID OF TWO ============================================================================= */
.span-2-of-2 {
width: 100%;
}
.span-1-of-2 {
width: 49.2%;
}
const allArr = []; //Not Sure how to work around this
const rapArr = [
"50 Cent || In Da Club",
"Beastie Boys || Pauls Boutique",
"B.G. || Bling Bling",
"Juvenile || I Got That Fire",
"Hot Boys || I Need A Hot Girl",
"Hot Boys || Let Em Burn",
"Big Tymers || How You Luv That ? Vol. 2",
"Lil Wayne || Respect Us",
"Lil Wayne || Get Off The Corner",
"Lil Wayne || 500 Degreez",
"Chamillionaire || Ridin / Southern Takeover",
"City High || What Would You Do?",
"Dead Prez || Its Bigger Than Hip-Hop",
"Deltron 3030 || Deltron 3030",
"Dizzee Rascal || Boy In Da Corner",
"Dr. Dre || The Chronic",
"Duice || Dazzey Duks",
"Goodie Mob || World Party",
"Grandmaster Flash || White Lines",
"Grandmaster Flash || Volume 22",
"Heavy D. & The Boyz || Now That We Found Love",
"Ice Cube || It Was A Good Day",
"Jay-Z || The Black Album",
"Mike Jones || Sampler",
"LL Cool J || Radio",
"Ludacris || Whats Your Fantasy",
"M.O.P. || 10 Years And Gunnin",
"Naughty By Nature || Hip Hop Hooray",
"OutKast || Aquemini",
"Paul Wall || Sittin' Sidewayz",
"P.M. Dawn || Set Adrift On Memory Bliss",
"Rob Base & DJ E-Z Rock || It Takes Two",
"Poison Clan || Shake Whatcha Mama Gave Ya'",
"Salt 'N' Pepa || Tramp (Remix) / Push It",
"Three 6 Mafia || Tear Da Club Up 97",
"Three 6 Mafia || Who Run It",
"T.I. || Urban Legend",
"Trick Daddy || In Da Wind",
"Warren G || This DJ",
"World Class Wreckin Cru || The Fly / He's Bionic",
"Ying Yang Twins || Badd",
];
const rbArr = [
"Amy Winehouse || Back to Black",
"The Chamber Brothers || Peace, Love and Understanding",
"Soul Train || Hits That Made It Happen",
"Archie Bell & The Drells || I Cant Stop Dancing",
"En Vogue || My Lovin (Never Gonna Get It)",
"Boyz II Men || Motownphilly",
"Billy Preston || Music Is My Life",
"Billy Preston || The Most Exciting Organ Ever",
"Billy Preston || The Kids & Me",
"Billy Preston || Billy Preston",
"Bill Withers || The Best Of Bill Withers",
"Bill Withers || Making Music",
"Bill Withers || Still Bill",
"Stevie Wonder || Innervision",
"Michael McDonald || If Thats what it takes",
"Ray Charles || Friendship",
"Color Me Badd || I Wanna Sex You Up",
];
const funkArr = [
"Cameo || Word Up!",
"Curtis Mayfield || Superfly",
"George Clinton || Computer Games",
"Funkadelic || The Electric Spanking Of War Babies",
"Funkadelic || Free Your Mind And Your Ass Will Follow",
"James Brown || Everybody's Doin' The Hustle",
"James Brown || Hot Pants",
"Johnny Jenkins || Ton-Ton Macoute!",
"Kool & The Gang || Wild And Peaceful",
"Parliament || Chocolate City",
"Prince || Purple Rain",
"Prince || Dirty Mind",
"Prince || Controversy",
"Prince || Prince",
"Rick James || Street Songs",
"Shotgun || Shotgun",
"Sly & The Family Stone || Greatest Hits",
"Sly & The Family Stone || There's A Riot Goin' On",
"Sly And The Family Stone || Stand!",
"The Time || Ice Cream Castle",
];
const progArr = [
// "Yes || The Yes Album",
"Dire Straits || Communiqué",
"Dire Straits || Dire Straits",
"Dire Straits || Brothers In Arms",
"Mike Oldfield || Tubular Bells",
"ELO || Out Of The Blue",
"ELO || Greatest Hits",
"ELO || A New World Record",
"ELO || On The Third Day",
"ELO || Face The Music",
// "Kansas || Leftoverture",
"Steely Dan || Pretzel Logic",
"Steely Dan || Aja",
"Steely Dan || Gaucho",
"Steely Dan || The Royal Scam",
"Steely Dan - Katy Lied",
"Steely Dan || Greatest Hits",
];
const rock60Arr = [
"The Animals || Best Of The Animals",
"The Band || Cahoots",
"The Beach Boys || Pet Sounds",
"The Creation - In Stereo",
// "The Beach Boys - Surfin' Safari",
// "Cream || Heavy Cream",
// "Cream || Wheels of Fire",
"Bob Dylan || Highway 61 Revisited",
"Bob Dylan || Greatest Hits",
"The Doors || 13",
"The Doors || Waiting For The Sun",
"The Doors || Absolutely Live",
"The Grassroots || Let's Live For Today",
"The Jimi Hendrix Experience || Smash Hits",
"The Kinks || Greatest Hits",
"Led Zeppelin || Houses Of The Holy",
"Led Zeppelin || Zoso",
"The Rolling Stones || Hot Rocks 1964—1971",
"Santana || Abraxas",
"Small Faces || First Step",
"Strawberry Alarm Clock || Incense And Peppermints",
"Tommy James And The Shondells || Mony Mony",
"Tommy James & The Shondells || The Best Of",
"Vanilla Fudge || Vanilla Fudge",
"The Zombies || Time Of The Zombies",
];
const rock70Arr = [
"Billy Squier || The Tale Of The Tape",
"CCR || The Best Of",
"Elvin Bishop || Let It Flow",
"Fleetwood Mac || Rumours",
"Fleetwood Mac || Fleetwood Mac",
// "Fleetwood Mac || Mirage",
"Gold Earring || Moontan",
"Heart || Barracuda",
"Jefferson Starship || Spitfire",
"Jefferson Starship || Freedom At Point Zero",
"Philip Lewin || Am I Really Here All Alone?",
"Little Feat || Down On The Farm",
"Little Feat || Feats Dont Fail Me Now",
"Montrose || Paper Money",
"Van Morrison || Moondance",
"Nilsson || Nilsson Schmilsson",
"Nilsson || The Point!",
"Nilsson || Son of Schmilsson",
"Nilsson || Pussy Cats",
"Bob Segar || Night Moves",
"Ted Nugent || Live",
"Van Morrison || It's Too Late To Stop Now",
"Van Morrison || Moondance",
"ZZ Top || Fandango!",
"ZZ Top || The Best Of ZZ Top",
"ZZ Top || Eliminator",
"ZZ Top || Tres Hombres",
];
const reggaeArr = [
"Dance Hall || Strictly The Best 5",
"Kevin Lyttle || Kevin Lyttle",
"Harder They Come || Various",
"Party Rockers Vol1 || Murder She Wrote",
"Wayne Smith || Under Me Sleng Teng",
"Studio One || Full Up",
"The Upsetters || Return Of The Super Ape",
];
const electroArr = [
"10cc || I'm Not in Love",
"Timex Social Club || Rumors",
"Cerrone 3 || SuperNature",
"C&C Music Factory || Gonna Make You Sweat",
"The Chemical Brothers || Exit Planet Dust",
"Deee-Lite || World Clique",
"Donna Summer || I Remember Yesterday",
"The Faint || Danse Macbre",
"Gary Numan || Pleasure Principle",
"Giorgio Moroder || Midnight Express",
"Giorgio Moroder || American Giglo",
"Giorgio Moroder || Knights in White Satin",
"Giorgio Moroder || From Here to Eternity",
"Fischerspooner || Emerge",
"Herbie Hancock || Future Shock",
"The Human League || Dare",
"The KLF || 3 A.M. Eternal",
"Kraftwerk - Die Mensch·Maschine",
"Miami Vice II || Soundtrack",
"Mr. Oizo || Flat Beat",
"Soft Cell || Tainted Love",
"Soul Sonic Force || Looking for the Perfect Beat",
"Soul Sonic Force || Planet Rock",
"Stereo MC's || Connected",
"Strafe / B.O.S.E. || Set It Off / Rock The World",
];
const altArr = [
"A.R.E. Weapons || A.R.E. Weapons",
"Adam And The Ants || Kings Of The Wild Frontier",
"The B-52s || Rock Lobster",
"The B-52's || Wild Planet",
"Big Audio Dynamite || Tighten Up Vol. 88",
"Big Audio Dynamite || Megatop Phoenix",
"Big Audio Dynamite || No. 10, Upping St.",
"Big Audio Dynamite || This Is Big Audio Dynamite",
"Blondie || Parallel Lines",
// "Blondie || AutoAmerican",
"Blondie || The Best Of Blondie",
"Dandy Warhols || Dandy Warhols Come Down",
"Death || ...For the Whole World to See",
"Devo || Are We Not Men? We Are Devo!",
"Elvis Costello || Get Happy!!",
"Elvis Costello || Blood & Chocolate",
"Elvis Costello || This Years Model",
"Elvis Costello || Armed Forces",
"Elvis Costello || Trust",
"EMF || Schubert Dip",
"ESG || South Bronx Story",
// "Fannypack || So Stylistic",
"Iggy Pop || Lust For Life",
"Japanther || Leather Wings",
"Lou Reed || The Best Of",
"The MC5 || Back in the USA",
"Tom Petty & The Heartbreakers || Self Titled",
"The Postal Service || Give Up",
"Rage Against The Machine || Rage Against The Machine",
"Ramones || Ramones Mania",
"Repo Man || Soundtrack",
"Scab || Sixth & New York",
"The Streets || Original Pirate Material",
"The Streets || A Grand Don't Come for Free",
"Supergrass || I Should Coco",
"Talking Heads || Speaking In Tongues",
"Traveling Wilburys || Volume One",
"Weezer || Weezer",
"White Stripes || White Stripes",
"White Stripes || De Stijl",
];
const metalArr = [
"Black Sabbath || Master Of Reality",
"Black Sabbath || Paranoid",
"David Lee Roth || California Girls",
"Deep Purple || Burn",
"Deep Purple || Fireball",
"Deep Purple || Who Do We Think We Are",
"Deep Purple || Shades Of Deep Purple",
"Deep Purple || Deep Purple",
"Deep Purple || Made In Japan",
"Deep Purple || Machine Head",
"Faith No More || We Care A Lot",
"Geezer || Psychoriffadelia",
"Guns N Roses || Appetite For Destruction",
"Iron Butterfly || In-A-Gadda-Da-Vida",
"Megadeth || Peace Sells... But Whos Buying?",
"Metallica || and Justice for All",
"Metallica || Kill em All",
"Metallica || Master of Puppets",
"Metallica || Ride the Lightning",
"Motörhead - Ace Of Spades",
"Poison || Open Up And Say ...Ahh!",
"Quiet Riot || Metal Health",
"Ratt || Out Of The Cellar",
"Saxon || The Eagle has Landed",
"Spinal Tap || Smell the Glove",
"Van Halen || Van Halen",
"Van Halen || 1984",
"White Zombie || La Sexorcisto: Devil Music Vol. 1",
];
const miscArr = [
"Jerry Jeff Walker || Navajo Rug",
"Françoise Hardy || Françoise Hardy",
"Glen Campbell || Greatest Hits",
"Los Teen Agers || 18 Exitos",
"George Gershwin || Rhapsody in Blue Porgy & Bess",
"Kenny Rogers || Greatest Hits",
"Slyvia || Slyvia",
"Dwight Yoakam || Just Lookin' For A Hit",
"Roy Orbison || Greatest Hits",
"George Jones || The Best Of George Jones",
"John Prine || In Spite Of Ourselves ",
"Overloaded Diesel || Overloaded Diesel",
"Merle Haggard || Mama Tried",
"Najwa Fouad || ليالي المولد = Layali El Mawled",
"Classic Country Music || 1920s (1)",
"Classic Country Music || 1930s SouthEast (2)",
"Classic Country Music || 1930s Southwest (3)",
"Classic Country Music || 1941-1953 (4)",
"Classic Country Music || 1941-1953 (5)",
"Classic Country Music || 1953-1963 (6)",
"Classic Country Music || Bluegrass (7)",
"Classic Country Music || 1963-1965 (8)",
"Goran Bregovic || Underground",
"Fadoul || Al Zman Saib",
"Omar Souleyman || Wenu Wenu",
"Randy Travis || Always & Forever",
"Willie Nelson || Shotgun Willie"
];
const popArr = [
"ABBA || The Singles",
"ABBA || Super Trouper",
"Ace Of Base || The Sign",
"Bryan Adams || Reckless",
"Bon Jovi || Slippery When Wet",
"The Cars || Candy-O",
"Phil Collins || Face Value",
"Phil Collins || No Jacket Required",
"Neil Diamond || Tap Root Manuscript",
"Neil Diamond || Stones",
"Neil Diamond || The Jazz Singer",
"Neil diamond || Live at the Greek",
"Neil Diamond || September Morn",
"Neil Diamond || Hot August Night",
"Neil Diamond || Rainbow",
"Go-Go's || Beauty And The Beat",
"Hall & Oates || Rock N Soul Part 1",
"Don Henley || Building The Perfect Beast",
"Huey Lewis & The News || Sports",
"Michael Jackson || Off The Wall",
"Michael Jackson || Thriller",
"Elton John || Greatest Hits",
"Madness || Madness",
"John Cougar Mellencamp || American Fool",
"Elvis Presley || On Stage - February, 1970",
"Pretty in Pink || OST",
"Sade || Diamond Life",
"Santa Esmarelda || Don't Let Me Be Misunderstood",
"Paul Simon || Graceland",
"Saturday Night Fever || Soundtrack",
"Paul Simon || Graceland",
"Wham! || Make it Big",
];
//Array of arrays
const genreArr = [
allArr,
progArr,
rock70Arr,
rock60Arr,
electroArr,
altArr,
metalArr,
rapArr,
rbArr,
funkArr,
reggaeArr,
popArr,
miscArr,
];
const containerDiv = document.querySelector(".container");
const cta = document.querySelector(".cta");
//Array of selected genre Arrays
let selected = [];
//Check/uncheck all boxes
document.getElementById("chkAll").onclick = function () {
const checkboxes = document.getElementsByName("genre");
for (const checkbox of checkboxes) {
checkbox.checked = this.checked;
}
};
containerDiv.addEventListener("click", function () {
//Clears Array
selected = [];
//Move IMG
containerDiv.style.marginTop = "32px";
cta.style.opacity=0;
// Remove previous
const removeInsert = document.getElementById("recordinsert");
while (removeInsert.firstChild) {
removeInsert.removeChild(removeInsert.firstChild);
}
//Checks checkboxes
const musicType = document.getElementById("musictype");
const chks = musicType.getElementsByTagName("INPUT");
// Loop and push the checked CheckBox value in Array.
for (let i = 1; i < chks.length; i++) {
if (chks[i].checked) {
selected = selected.concat(genreArr[i]);
// selected = [...selected, ...genreArr[i]];
}
}
//Number of albums from selector
const numRecords = document.getElementById("num-records").value;
//Inserts selections in to HTML
for (let i = 0; i < numRecords; i++) {
const randomNumber = Math.trunc(Math.random() * selected.length);
const full = selected[randomNumber].split(" || ");
const band = full[0];
const album = full[full.length - 1];
document
.getElementById("recordinsert")
.insertAdjacentHTML(
"afterbegin",
`<div class="row random-record"><h2>${album}</h2><h3>${band}</h3></div>`
);
}
});
Also see: Tab Triggers