Let's say I have to remember the initial height of some element. The general practice that I see is to save this value using $.datafor this element.
$.data
I do not understand the benefits of this. Why not just save a simple variable with this value or an array with values if there are multiple elements? Saves code that is easy to understand.
It allows you to reuse a function to apply the same effect to other elements (without having to deal with closure).
It allows you to initialize a value using HTML.
.
data() , , ,
data()
$('.elements').on('click', function() { $(this).data('value', this.value); }); $('.elements').on('keyup', function() { $(this).val( $(this).data('value') ); });
, , data() , , .
, INSIDE A NODE, . NODE, node
Source: https://habr.com/ru/post/1546714/More articles:Use Reflection.Emit to create types that reference each other - reflectionKassandra's Atomicity and Rollback - cassandraGuide Textures and Wildfly - PushiOS Facebook Graph API Use the "next" or "previous" URL to paginate using the SDK - iosReturning a single object from OData -.Net - c #Как создать выражение запроса для Odata для получения по Id - c#F # variable list is zero - f #Google SDK "sharedWithMe = false" search query does not work - google-drive-sdkinterface interface pointer and destination value - goAuthorize_code provide stream in Owin.Security.OAuth: returns invalid_grant - asp.netAll Articles