Vote Up 0 Vote Down

How to store data in a HTML field ?

How to store data in a HTML field ?
flag

Answers


Vote Up 0 Vote Down
You can store data in a HTML field like follow :

<div id="mydiv" data-mydata="hello world">


To retrieve the data using jquery :

var mydata = $("#mydiv").data("mydata");
alert(mydata); //Alerts as "hello world"
flag | link |

Your Answer

Login before answering

Login with facebook