mardi 5 septembre 2017

can we pass a variable to data attribute of html

So far i know that we can store data in html element by using:

<div  data-test="hello">
$.("div").data("test")

However , i just can store raw text for data attribute

what i need is:

var t= hello
<div  data-test=t>

but when i did that , it show the letter t instead of hello

please help

Aucun commentaire:

Enregistrer un commentaire