A Pen by Tim

Thumbnail
This awesome code was written by tevko, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright tevko ©
  • HTML
  • CSS
  • JavaScript
    <div class="container">
	<input class="min" type="range" min="10000" step="1000" max="10000000" value="10000">
	<input class="max" type="range" min="10000" step="1000" max="10000000" value="10000000">
	
	Min: <input type="text" class="minValue">
	Max: <input type="text" class="maxValue">
</div>



/*Downloaded from https://www.codeseek.co/tevko/a-pen-by-tim-MXWXLx */
    body {
	margin: 3em;
}

input {
	display: block;
	margin-bottom: 1em;
}

input[type='range'] {
	width: 100%;
}

.container {
	max-width: 600px;
}




/*Downloaded from https://www.codeseek.co/tevko/a-pen-by-tim-MXWXLx */
    

document.body.addEventListener('input', e => {
	if (e.target.classList.contains('max')) {
		document.querySelector('.maxValue').setAttribute('value', `${Number(e.target.value).toLocaleString('en-US', { style: 'currency', currency: 'USD' })}`);
	} else {
		document.querySelector('.minValue').setAttribute('value', `${Number(e.target.value).toLocaleString('en-US', { style: 'currency', currency: 'USD' })}`);
	}
});

Comments