You cannot pass the parameters like that. You need to pass it like:
$( ".animals li" ).each((ind, el) => color(ind, el, "green"));
That will do it. However, you need to fix your color function to not use 'this':
function color( index, element, text_color ) {
if( index % 2 != 0 ) {
$( element ).css( "color", text_color );
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…