/ Published in: jQuery

jQuery has a built in method that allows developers to store information inside elements. Learn how to use the .data() method and view some examples of how this can be used.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
//Store information $("input").data("original", "$1.75"); $("input").data("currency", "$1.50"); $("input").data("decimal", 1.5); //Retrieve information $("input").data("original"); $("input").data("currency"); $("input").data("decimal"); //Shorthand store $("input").data("numbers",{original: "$1.75", currency: "$1.50", decimal: 1.5}); //Shorthand retrieve $("input").data("numbers").original; $("input").data("numbers").currency; $("input").data("numbers").decimal;
URL: http://www.nealgrosskopf.com/tech/thread.php?pid=69
Comments
