1

I have the following code and it works correctly in FF and IE8 but fails in IE 7 anyone have an idea or hack

    if ($("#midRight:contains('Quick Links')").length == 0) {
  $("#midCenter").css({'width':'298px'});
 }

html is basic

    <div id="midRight">
bunch of text
</div>

the starting css is

#midRight {width:440px;}

IE7's javascript error is "Object doesn't support this property or method. BTW if I throw an alert in BEFORE the width change it works fine. If I move the alert to after the width change it never fires so at least I know that the conditional statement works right in IE7 just not the change of width.

3
  • Please add more details such as: HTML code, what do you mean by it fails? Commented Nov 18, 2009 at 19:48
  • Which bit fails - the if() or setting the width? Commented Nov 18, 2009 at 19:48
  • 1
    Need more HTML and the CSS you have for #midCenter as it is before the jQuery modification. Commented Nov 18, 2009 at 19:51

3 Answers 3

5
$("#midCenter").css({width:298});
Sign up to request clarification or add additional context in comments.

2 Comments

Either this, or $("#midCenter").css('width, '298px');
very strange I thought I had tried all possible combinations but turns out removing the quotes and the px from the value solved the problem. $("#midCenter").css({'width':298});
0

This may be a bug in the way IE7 handles setting the width with CSS. Does it work any better if you set the width directly?

if ($("#midRight:contains('Quick Links')").length == 0) {
    $("#midCenter").width(298);
}

Comments

0

Are you waiting for the DOM to finish loading? Try this:

$(function()
{
    if ($("#midRight:contains('Quick Links')").length == 0)
      $("#midCenter").css({'width': 298});
});

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.