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?