Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML DOM Object data Property
The HTML DOM Object data property returns a string corresponding to the value of the attribute data.
Following is the syntax −
Returning string value
ObjectElement.data
Set data property to a string value
ObjectElement.data = URLString
Let us see an example of HTML DOM Object data property −
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML DOM Object data</title>
<style>
form {
width:70%;
margin: 0 auto;
text-align: center;
}
* {
padding: 2px;
margin:5px;
}
input[type="button"] {
border-radius: 10px;
}
</style></head>
<body>
<form>
<fieldset>
<legend>HTML-DOM-Object-data</legend>
<object id="objSelect" height="200" data="https://www.tutorialspoint.com/python_blockchain/images/python-blockchain-mini-logo.jpg"> </object>
<input type="button" onclick="getObjectData()" value="Get URL">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var objSelect = document.getElementById("objSelect");
function getObjectData() {
objSelect.data
divDisplay.textContent = 'URL of above picture: '+objSelect.data;
}
</script>
</body>
</html>
Output
Before clicking ‘Get URL’ button −

After clicking ‘Get URL’ button −

Advertisements