Javascript DOM HTML Object name Property get

Introduction

Get the name of an <object> element:

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

Click the button to display the name of the object.

View in separate window

<!DOCTYPE html>
<html>
<body>

<object id="myObject" 
        width="100" 
        height="100" 
        data="video.mp4" 
        name="obj1"></object>
        //from  ww  w.  ja  v a2  s .c o m
<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {
  var x = document.getElementById("myObject").name;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The name property sets or gets the value of the name attribute of an <object> element.

The name attribute specifies the name of an object.

The name property returns a String representing the name of the <object> element.




PreviousNext

Related