In my Sharepoint portal I am trying to fix a problem where the lists are wider than the page borders (custom master page) and look funny when they display on the far right. So I am writing a jQuery function that will reset the width.

My function works fine, so fine that it works in Sharepoint dialogues, too - but I don't want it to work in dialogues!

Here is my method of selecting the elements, which works. 

```
var elements = $(".s4-wpcell-plain > div > *, #pagebody.s4-ca > div > *");

```

However, I want to exclude matching if the page is run in a dialogue. Now, there is a `.ms-dlgContent` style, but it is way above (like, parent of parent of parent, etc...) any of the elements I'm using in my selector match.

How can I match my element if there is no predecessor that matches that class?

**[update]**

Well, thank you, faithful jQuery gurus for such quick responses. But I tried all of your techniques and it doesn't quite do the trick, so let me explain a bit more (sorry I didn't think of this before). 

Here is the css path to the `#pagebody` div in the dialogue. You can see the class specifying the dialog at the start.

> 
> html.ms-dialog body form#aspnetForm div#s4-workspace.s4-nosetwidth
>  div#s4-bodyContainer div#ctl00\_MSO\_ContentDiv div#pagebody.s4-ca
> 
> 
> 

This is the css path of the `#pagebody` element for the regular page.

> 
> html body form#aspnetForm div#s4-workspace.s4-nosetwidth
>  div#s4-bodyContainer div#ctl00\_MSO\_ContentDiv div#pagebody.s4-ca
> 
> 
> 

So, I need to affect the `#pagebody` for just the main page and not the dialogue. Keep in mind that I want to avoid selecting anything based on the Sharepoint-generated GUIDs.

**[edit]**

Uh, sorry, after looking at those paths, now I realize I have to use `ms-dialog` instead ot `ms-dlgContent`. I'll mark the answer now.