WinJS.Utilities.data function
Gets the data value associated with the specified element.
Syntax
var object = WinJS.Utilities.data(element);
Parameters
element
Type: DOMElementThe element.
Return value
Type: Object
The value associated with the element.
Examples
The following code shows how to use this method. the data on the child nodes of the DIV element are the ratings stars, and the msStarRating property gives the value of the rating (Windows only).
<div id="ratingDiv" data-win-control="WinJS.UI.Rating"></div>
<script type="text/javascript">
WinJS.UI.processAll();
var div = document.getElementById("ratingDiv");
var children = div.childNodes;
var i = 0;
while (i < children.length) {
var child = children[i++];
if (WinJS.Utilities.hasClass(child, "win-star")) {
var rating = WinJS.Utilities.data(child);
var value = rating.msStarRating;
}
}
</script>
Requirements
Minimum WinJS version |
WinJS 1.0 |
Namespace |
WinJS.Utilities |