Nick
Nick

Reputation: 1243

Checking for IE7/IE6 in jQuery

I have a function where it needs to make allowances for the fact IE6/IE7 does not have the same support as other browsers, as follows:

if ($.browser.msie && $.browser.version.substr(0,1)<8) {
  $('table tr:nth-child(2n+1)').addClass('alternativeRow');
}

This has always worked fine, until I've just installed IE8 and I get a Javascript error message saying:

'$.browser' is null or not an object

I appreciate $.browser may not be the best way of checking these things anyway, so I was wondering if there was a way around it?

Thanks

(edit) to add a little context, I am simply trying to add a 'zebra' esque table layout since we deal with lots of data and it can be hard to analyse if each row looks the same

Upvotes: 0

Views: 675

Answers (2)

theoretical
theoretical

Reputation: 420

.browser was deprecated in jQuery 1.3. The recommended solution is to use .support

Upvotes: 1

BentOnCoding
BentOnCoding

Reputation: 28158

Quit Browser Sniffing and start feature sniffing.

http://modernizr.com/

Upvotes: 1

Related Questions