Skip to content

Instantly share code, notes, and snippets.

@justinpenner
Last active March 27, 2022 02:02
Show Gist options
  • Save justinpenner/98b4ac0d47f2c7279ebb65e454673a5d to your computer and use it in GitHub Desktop.
Save justinpenner/98b4ac0d47f2c7279ebb65e454673a5d to your computer and use it in GitHub Desktop.
// Declare and assign our main variables
let tt = document.querySelector('.tt_wrapper');
let sliders = {};
sliders.size = document.createElement('input');
let samp = document.createElement('samp');
// Clear the contents of .tt_wrapper
tt.innerHTML = '';
// Add attributes to the slider <input>
sliders.size.type = 'range';
sliders.size.min = 16;
sliders.size.max = 256;
sliders.size.step = 1;
sliders.size.dataset.units = 'px'; // dataset holds custom data-* attributes
// <samp> needs some attributes too
samp.innerText = 'The swift red fox leaps over the proud dachshund!';
samp.contentEditable = true;
// Attach our elements to the wrapper!
tt.appendChild(sliders.size);
tt.appendChild(samp);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment