views:

49

answers:

1

Hello all,

I make use of class selectors in JQuery and this works fine but in IE6 this fails as it does not apply the width I would like.

    $('.ui-state-default .ui-jqgrid-hdiv').css('width', width);

If I try it one class it works?? But I need to apply that width to a div that has both those classes.

Thanks all for any help.

Update

$onselect = <<<loadComplete
function go_size(){

        var width = document.documentElement.clientWidth - 45;
        $('#gbox_grid').css('width', width);
        $('#gview_grid').css('width', width);
        $('#pager').css('width', width);
        $('.ui-state-default .ui-jqgrid-hdiv').css('width', width);
        $('.ui-jqgrid-bdiv').css('width', width)

}
loadComplete;
+4  A: 

Remove the space between the class names. With your posted selector, you search for a child element .ui-jqgrid-hdiv inside a parent .ui-state-default.

Look here (W3C) and here (jQuery) for how to write selectors.

Also, look, if the class attribute spans multiple lines in the HTML source. IE 6 can't handle that correctly.

Boldewyn
+1 Yes, several caveats as noted with IE.
Mark Schultheiss
Fantastic! I just removed the space and it worked. I didn't realise it worked like that?! Thank you Boldewyn!
Abs
@Abs: I suggest you to read the jQuery docs about selectors. You can do amazing things with selectors *even* (almost) *completely without* harming elements with class names or IDs.
Boldewyn
@Boldewyn - I will have a read of those two links since I really need to no more about selectors as I will be doing quite a fair bit of work with JQuery.
Abs