Home  >  jQuery

Example of .data() in jQuery

April 29, 2013
.data() in jQuery works as collection. We can store data as key value pair. .data() also returns value fetched by key. Syntax is
data( key, value )
data( key )
Find the example.

<!DOCTYPE html>
div { color:green; }
p { color:blue; }
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
Hi, this is 
here, we learn a lot
$("div").data("datatest", { a: "concretepage.com",b:"in jQuery" });


©2022 concretepage.com | Privacy Policy | Contact Us