Javascript DOM HTML Input Range name Property

Introduction

Get the name of a slider control:

var x = document.getElementById("myRange").name;

Click the button to display the value of the name attribute of the slider control.

View in separate window

<!DOCTYPE html>
<html>
<body>

<input type="range" id="myRange" name="points">

<button onclick="myFunction()">Test</button>
<p id="demo"></p>

<script>
function myFunction() {//ww w  .j a v a  2s  .  com
  var x = document.getElementById("myRange").name;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The name property sets or gets the value of the name attribute of a slider control.

The name attribute can identify form data after submitting to the server.

Only form elements with a name attribute will be passed to the server.

The name property accepts and returns a String type value.




PreviousNext

Related