I want to add CSS to every element of an array
My current code is
var elaboration = $('.conception-competences-elaboration').children('img');
var realisation = $('.conception-competences-realisation').children('img');
var conception = $('.conception-competences-conception').children('img');
function up() {
elaboration.on('mouseover', function() {
elaboration.css('padding-bottom', '5px');
elaboration.css('cursor', 'pointer');
})
realisation.on('mouseover', function() {
realisation.css('padding-bottom', '5px');
realisation.css('cursor', 'pointer');
})
conception.on('mouseover', function() {
conception.css('padding-bottom', '5px');
conception.css('cursor', 'pointer');
})
}
This works but I want to get less lines of code, so I created an array and I tried this :
var actionsArray = ['elaboration', 'realisation', 'conception'];
function up() {
for (var i = 0; i < actionsArray.length; i++) {
actionsArray[i].on('mouseover', () => {
actionsArray[i].css('padding-bottom', '5px');
actionsArray[i].css('cursor', 'pointer');
})
}
}
But it doesn't work, can someone help me ?
Thank you !