2
In the code that follows below, I would like to pass and remove the mouse (mouseover and mouseout) about a li
, the change was made only in the item corresponding to that li
, in the case, the tags a
and i
within the li
, in the same way as with code CSS (background and color tag i
altered with Hover). The problem I have now is that when I trigger the event, instead of just changing the element within the li
where the mouse is on at the moment, all the elements are affected at once.
To get better follow the codepen link with the full code: http://codepen.io/RaoniSousa/pen/wJqdNP
I’d appreciate it if you could help.
function abc() {
var myLi = document.querySelectorAll('li'),
icons = document.querySelectorAll('li i'),
//MOUSEOVER
function changeI() {
'use strict';
if (icons.length) {
for (var i = 0; i < icons.length; i++) {
icons[i].style.fontSize = '2em';
}
}
}
//MOUSEOUT
function backI() {
'use strict';
if (icons.length) {
for (var i = 0; i < icons.length; i++) {
icons[i].style.fontSize = '1em';
}
}
}
if (myLi.length) {
for (var i = 0; i < myLi.length; i++) {
myLi[i].addEventListener("mouseover", changeI);
myLi[i].addEventListener("mouseout", backI);
}
}
}
abc();
I was preparing the answer using the
transform scale
kk– Woss
@Andersoncarloswoss and would be a good answer. Also puts!
– Sergio
Before I did with css, but the js thing was more for study anyway, I’m new in the area and I was curious. Thanks for the tips.
– Raoni Batista de Sousa
I understood your solution, very good, but when I run my test with it does not work and on the console appears: Uncaught Typeerror: Cannot read Property 'style' of Undefined at Htmllielement.<Anonymous>, which is related to the expression: el.style.fontsize = size; What’s the problem there? Thank you, man.
– Raoni Batista de Sousa
@Raonibatistadus takes a look inside the
for
and makes a console.loga ambos
liBArray[i]e
iconsArray[i]`. It gives me the idea that there is no icon for every lib..– Sergio
Oh yes, now it worked, I just changed the dials. 

 var liB = document.querySelectorAll('#footFlex li'), 
 liBArray = Array.prototype.slice.call(liB), 
 icons = document.querySelectorAll('#footFlex li i'), 
 iconsArray = Array.prototype.slice.call(icons);

Obrigado, man.
– Raoni Batista de Sousa