<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery.data demo</title>
<style>
div {
color: blue;
}
span {
color: red;
}
</style>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<div>
The values stored were
<span></span>
and
<span></span>
</div>
<div style="background:notification.png no-repeat;height:imageheight px;width:imagewidth px">
</div>
<div id="container">
<img src="notification.png" alt="" />
<div id="containera">
</div>
</div>
<script>
var div = $( "div" )[ 0 ];
jQuery.data( div, "test", {
first: 16,
last: "pizza!"
});
$( "span:first" ).text( jQuery.data( div, "test" ).first );
$( "span:last" ).text( jQuery.data( div, "test" ).last );
$( "span:last" ).attr('data-count', 1);
$( "#containera").text( 1);
</script>
</body>
</html>
No comments:
Post a Comment