<p>I am using some nested layouts in Ruby on Rails, and in one of the layouts i have a need to read in a string from a div and set that as the title of the document. What is correct way (if any) to set the title of the document?</p>

<pre><code>&lt;script type="text/javascript"&gt;
$(document).ready(function() {

    // ???

});
&lt;/script&gt;
</code></pre>

Like this:
```
```
$(document).ready(function ()
{
    document.title = "Hello World!";
});
```
```
Be sure to set a default-title if you want your site to be properly indexed by search-engines.
A little tip:
```
```
$(function ()
{
    // this is a shorthand for the whole document-ready thing
    // In my opinion, it's more readable 
});
```
```