Javascript examples for jQuery:Data Attribute
Store values in html data attribute
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-3.1.1.js"></script> <script type="text/javascript"> window.onload=function(){/* ww w. ja v a 2s .c om*/ var colors = $("span").data("fruits").split(" "); console.log(colors); } </script> </head> <body> <span data-fruits="mango apple banana"></span> </body> </html>