Q:

Retrieve the stored value from the division element using jquery

0

Retrieve the stored value from the division element using jquery

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

HTML Code :

<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-git.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Retrieve the stored  value from the div element.</title>
</head>
<body>
<div>
My favorite colors are
<span></span>
and
<span></span>
</div>
</body>
</html>

JavaScript Code :

$( "div" ).data( "test", { first: "Red", last: "Green." });
$( "span:first" ).text( $( "div" ).data( "test" ).first );
$( "span:last" ).text( $( "div" ).data( "test" ).last );

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now