I read that to improve the performance of jquery should avoid use because some things are slowing down a bit.
Among these is the method each()
and that it would be appropriate to use a for loop ... (according to the web article I read, the method each()
takes roughly 10 times greater than for loops javascript)..
I'm trying to used js but I have some problems: /
Jquery
$('#block-system-main-menu li').each(function () {
var text= ($(this).children('a').text());
if (text == 'Map' || text== 'Vul' || text== 'Equa'){
$(this).children('a').append('<span style="float:right; margin-right: 15%; line-height: inherit;" class="fa fa-chevron-right"></span>');
}
});
Javascript
var voce= $('#block-system-main-menu li');
for(var i=0; i< voce.length; i++) {
var text= (voce[i].children('a').text());
if (text == 'Map' || text== 'Vul' || text== 'Equa'){
voce[i].children('a').append('<span style="float:right; margin-right: 15%; line-height: inherit;" class="fa fa-chevron-right"></span>');
}
}
but the loop does not work and I do not understand why ....
Thanks!