IE Can Cause Hair-Loss

Published on 2nd Dec, 2015

*eye-twitch*

Fewer things frustrate me more than IE (Internet Explorer) does. Most of the time it's my fault. I should've known better, should've been neater with my code, should've knelt and prayed before the Windows Logo, etc.

My most recent struggle was with the following code:

function highlight_rows(row){
    item = $(row);
    item.unhighlight();
}
Pretty simple. This function passes in an HTML row from a table, I grab a jQuery object from it, then call the unhighlight method from my plugin. Easy peasy.

But it's not.

In IE:

Hit my head on the wall for a few hours before remembering that I'd dealt with this specific issue before...many times. IE doesn't like you to use item as a variable name. For some reason this little tidbit never fully sinks into my brain. So maybe writing this out will help save me some time in the future. Don't use item as a variable name, at least not for a jQuery object. Mainly, you should avoid doing it because it's not a helpful or descriptive variable name (I ended up going with objRow), but secondly because IE will throw a fit and potentially ruin your day.

Go in peace...with Chrome.

Take care,

Richard

This article is my 24th oldest. It is 200 words long

comments powered by Disqus