I know understand more about how jQuery stores data.
Is there any advantage to doing one or the other of these:
$(\'#editCity\').data(\'href\', \"xx\");
The most interesting point about the data function is that you can add any kind of object, for example your modal
. And jQuery, as stated in the documentation, take care of avoiding memory leaks when the DOM changes :
The jQuery.data() method allows us to attach data of any type to DOM elements in a way that is safe from circular references and therefore free from memory leaks.
For strings, memory leaks aren't possible but the main difference is that the first solution is cleaner (more coherent if you might store other data than strings in other parts of your application), clearer (the intent is evident), and doesn't force CSS calculation (DOM isn't changed).