I have tried my best to understand this but cannot understand why 'this' is not working in first code but works in second code example.
First (this doesnt work here)
$('#' + ID).parent().siblings().each(function() {
selectChildren();
});
function selectChildren() {
$(this).children('.left-links-dashboard').css({
'color': 'grey'
});
//this one doesn't work..why ????
}
Over here the selectChildren() function has an argument and when calling the function this is passed to function and it works..
Second
$('#' + ID).parent().siblings().each(function() {
selectChildren(this);
});
function selectChildren(esd) {
$(esd).children('.left-links-dashboard').css({
'color': 'grey',
'font-weight': '400'
});
$(esd).children('.left-links-dashboard').children('i').removeClass('fa-arrow-circle-right').addClass('fa-angle-right');
}
Have read through stackoverflow, MDN and other resources but couldn't understand why the second code example works. Any explanation would really help me. Thanks