A Pen by Todd Wolfson

Thumbnail
This awesome code was written by twolfson, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright twolfson ©
  • HTML
  • JavaScript
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>A Pen by  Todd Wolfson</title>
  
  
  
  
  
</head>

<body>

  <div id="valueless">
  <input type="checkbox" checked>
  <input type="checkbox">
  <input type="radio" checked>
  <input type="radio">
</div>
<div id="valueful">
  <input type="checkbox" checked value="abc">
  <input type="checkbox" value="def">
  <input type="radio" checked value="ghi">
  <input type="radio" value="jkl">
</div>
  
  

    <script  src="js/index.js"></script>




</body>

</html>

/*Downloaded from https://www.codeseek.co/twolfson/a-pen-by-todd-wolfson-bNKJBZ */
var $inputs = [].slice.call(document.querySelectorAll('#valueless input'));

$inputs.forEach(function getValue ($input) {
  console.log($input.value);
});

$inputs = [].slice.call(document.querySelectorAll('#valueful input'));

$inputs.forEach(function getValue ($input) {
  console.log($input.value);
});

Comments