Hiding multiple elements' parent container (by child element id) Summary:

I need to hide several (pre-determined) divs based on a child element's ID.



Caviats:

I can't alter the HTML directly in any way (by modifying the literal .html file).  The IDs of the child elements for which the parents are to be hidden are known and not likely to change often (or even at all).

I can't add CSS that will be available to the HTML page.



Here is the solution that I came up with

JavaScript

var toHide = $("#item2, #item3, #item6");
toHide.parent().hide();


HTML

&lt;div id="container"&gt;
    &lt;div&gt;
        &lt;div id="item1"&gt;
            &lt;p&gt;item 1&lt;/p&gt;
        &lt;/div&gt;
        &lt;div&gt;related item stuff&lt;/div&gt;
    &lt;/div&gt;
    &lt;div&gt;
        &lt;div id="item2"&gt;
            &lt;p&gt;item 2&lt;/p&gt;
        &lt;/div&gt;
        &lt;div&gt;related item stuff&lt;/div&gt;
    &lt;/div&gt;
    &lt;div&gt;
        &lt;div id="item3"&gt;
            &lt;p&gt;item 3&lt;/p&gt;
        &lt;/div&gt;
        &lt;div&gt;related item stuff&lt;/div&gt;
    &lt;/div&gt;
    &lt;div&gt;
        &lt;div id="item4"&gt;
            &lt;p&gt;item 4&lt;/p&gt;
        &lt;/div&gt;
        &lt;div&gt;related item stuff&lt;/div&gt;
    &lt;/div&gt;
    &lt;div&gt;
        &lt;div id="item5"&gt;
            &lt;p&gt;item 5&lt;/p&gt;
        &lt;/div&gt;
        &lt;div&gt;related item stuff&lt;/div&gt;
    &lt;/div&gt;
    &lt;div&gt;
        &lt;div id="item6"&gt;
            &lt;p&gt;item 6&lt;/p&gt;
        &lt;/div&gt;
        &lt;div&gt;related item stuff&lt;/div&gt;
    &lt;/div&gt;
    &lt;div&gt;
        &lt;div id="item7"&gt;
            &lt;p&gt;item 7&lt;/p&gt;
        &lt;/div&gt;
        &lt;div&gt;related item stuff&lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;


Is there a better way to select these multiple elements than by using $("#item2, #item3, #item6")?

Are there any options I'm missing?
That is pretty close to the optimal way of doing it.

Personally I would go for

//Hide items
$("#item2, #item3, #item6").parent().hide();