<p>I'm wanting to add a class to the body tag without waiting for the DOM to load, but I'm wanting to know if the following approach would be valid. I'm more concerned with validity than whether the browsers support it for now.</p>

<pre><code>&lt;body&gt;
  $("body").addClass("active");
  ...
&lt;/body&gt;
</code></pre>

<p>Thanks,
Steve</p>

If the element doesn't exist in the DOM, the search will fail to find it and the action won't be applied.   If you can't do it in the $(document).ready() function, you might want to try putting the code after the element being referenced.  I believe this will work.
```
```
<body>
   <div id='topStories'></div>
   <script type='text/javascript'>
     $('div#topStories').addClass('active');
   </script>
</body>
```
```
If you need to add the class to the body, I would definitely use $(document).ready().