Input Range name Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Range

Description

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

Set the name property with the following Values

Value Description
name Sets the name of the slider control

Return Value

A String, representing the name of the slider control

The following code shows how to get the name of a slider control:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

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

<button onclick="display()">Display name</button>
<button onclick="change()">Change name</button>

<script>
function display() {
    var x = document.getElementById("myRange").name;
    console.log("The name of the slider control is: " + x);
}

function change() {/* w w w.java2 s  . c  o  m*/
    var x = document.getElementById("myRange").name = "newRangeName";
    console.log("The name was changed to: " + x);
}
</script>

</body>
</html>

Related Tutorials