Javascript DOM HTML Input Range name Property set

Introduction

Change the name of a slider control:

document.getElementById("myRange").name = "newRangeName";

Click the buttons to display and change 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">
<p id="demo"></p>

<button onclick="display()">Display name</button>
<button onclick="change()">Change name</button>
<script>
function display() {
  var x = document.getElementById("myRange").name;
  document.getElementById("demo").innerHTML = "The name of the slider control is: " + x;
}

function change() {//from   ww w . j  av  a  2 s.  c om
  var x = document.getElementById("myRange").name = "newRangeName";
  document.getElementById("demo").innerHTML = "The name was changed to: " + x;
}
</script>

</body>
</html>



PreviousNext

Related