Do you have any preferences for below code code snippet? What approach do you follow when your site have too many fields. Option 1:
PriorityOfAccessModel:
{
Id: $('#divPriorityAccess #Id').val(),
FamilyId: $('#divkPriorityAccess #FamilyId').val(),
ChildId: $('#divkPriorityAccess #ChildId').val(),
Comment: $('#divkPriorityAccess #Comment').val(),
CreatedBy: $('#divkPriorityAccess #CreatedBy').val(),
CreatedOn: $('#divkPriorityAccess #CreatedOn').val(),
Categories: accessPriority.getCategory(),
Allocating: { Id: allocating }
}
Option 2 :
var $x = $('#divPriorityAccess');
var accessModel =
{
Id: $x.find('#Id').val(),
FamilyId: $x.find('#FamilyId').val(),
ChildId: $x.find('#ChildId').val(),
Comment: $x.find('#Comment').val(),
CreatedBy: $x.find('#CreatedBy').val(),
CreatedOn: $x.find('#CreatedOn').val(),
Categories: accessPriority.getCategory(),
Allocating: { Id: allocating }
};
Option 3:
var $y = $('#divkPriorityAccess');
var accessModel =
{
Id: $('#Id', $y).val(),
FamilyId: $('#FamilyId', $y).val(),
ChildId: $('#ChildId', $y).val(),
Comment: $('#Comment', $y).val(),
CreatedBy: $('#CreatedBy', $y).val(),
CreatedOn: $('#CreatedOn', $y).val(),
Categories: accessPriority.getCategory(),
Allocating: { Id: allocating }
};
Context:
Quote:
$('.child', parentContext); Ops/Sec: 105,442 ±7.03% fastest
Find:
Quote:
$(parentContext).find('.child'); Ops/Sec: 113,119 ±10.53% fastest
My above finding is based on
Quote: