Using $(this).children(a) with IE vs Mozilla

The code below works fine in Firefox but doesn’t work in IE8. Is that to be expected and if so, why?

if (($(this).children(a).text()) == ‘Hide’)

If I change it to – if ($(‘.accordionShow .head a’).text() == ‘Hide’) it works fine but I lose the ability to use ‘this’, which I would like to have.

The HTML is

<div class=“accordionShow”>
<h2 class=“head”><a href=“#”>Hide</a> the Section</h2>
</div>

What I want to do is be able to identify the label as Hide or Show without getting the whole text, i.e. ‘Hide the Section’. That way no matter what the label is it will work the same. And I could substring it I suppose by using the text of the <h2> tag but it seems that is unnecessary also.

Is this just another peculiarity of IE, that it doesn’t use the .children(a) selector?

I found it. IE is a little more stringent and requires the use of quotes around the a as in

if (($(this).children(‘a’).text()) == ‘Hide’)

and then it seems to work fine.

If anyone can confirm that independently that would be great. Thanks

Yep, you should be using quotes. Firefox probably should have failed without them.

Thanks for confirming that. I appreciate it.