Поскольку вы использовали data
атрибуты в вашей разметке, вы можете получить к ним доступ, используя метод jQuery
data
. Также я кэшировал объект jquery в локальные переменные, которые используются с кратными в цикле, что поможет улучшить производительность.
// iterate through each group in groups
var $groups = $('div[id^="group"]'), $group, currentGroup, $sections, currentSection, $inputs;
$.each($groups, function(key, group) {
$group = $(group);
currentGroup = $group.data('group');
// iterate through each section in group
$sections = $group.find('div[id^="section"]');
$.each($sections, function(key, section) {
currentSection = section.data('section');
$inputs = $section.find("input");
inputs.each(function(){
fnValidateDetails(currentGroup, currentSection, this.name, this.value)
})
});
})
;