Я пытаюсь использовать цикл для вывода значений из двух массивов в функции наведения jQuery.За пределами наведения я могу получить доступ к этим значениям массива, но внутри я получаю неопределенное значение.
JavaScript все еще для меня нов, поэтому, пожалуйста, сообщите мне о любых моих ошибках новичка.Спасибо.
jQuery(document).ready(function($){
var originalWheelContent = $('.wheel-content').html(),
transitionSpeed = 400,
segmentTitle = ['collaborative','compassionate','inclusive','empowering','responsive'],
segmentParagraph = [
'Working together to deliver the best possible outcomes and recognises and values the contribution of others.',
'Constantly looking for new ways to satisfy the needs of those you work with or care for. Acting with consideration and understanding for others feelings.',
'Actively seeking and creating opportunities to include others, fostering an environment where everyone feels valued and respected.',
'Enabling positive change and supporting others to reach their maximum potential.',
'Reacting positively to change and others needs by being creative and innovative in finding solutions.'
];
for(x = 0; x < segmentTitle.length; x++){
$('.wheel-graphic map area#' + segmentTitle[x]).hover(
function(){
$('.wheel-content').fadeOut(transitionSpeed,function(){
$('.wheel-content').replaceWith('<div class="wheel-content"><h2 class="segment-title">' + segmentTitle[x] + '</h2><h4 class="segment-p">' + segmentParagraph[x] + '</h4></div>');
});
}, function() {
$('.wheel-content').fadeIn(transitionSpeed);
$('.wheel-content').replaceWith('<div class="wheel-content">' + originalWheelContent + '</div>');
}
);
}
});
![enter image description here](https://i.stack.imgur.com/1VMsQ.png)