jquery - reveal answer in definition list
<p>I have an FAQ page that looks like the markup shown below</p>

<p>When the page loads I'd like to reveal the answer that corresponds to the bookmark in the URL</p>

<p>The url will be of the form www.mydomain.com/page#q1</p>

<p>I am trying to do it like this but it wont't work - any ideas how to fix it?</p>

<pre><code>console.log($(hash).length)
</code></pre>

<p>does have a length of 1 so it is selecting a dom element</p>

<p>And I have used the same functionality to reveal it on click further down the script - and tht works OK</p>

<pre><code>$(function () {

        var hash = window.location.hash;
        //hash = hash.replace('#', '');
        console.log('hash:' + hash);
        console.log($(hash).length);

        $(hash)
            .parent()
            .parent()
            .find("dd.answer")
            .slideToggle();

        $("dd.answer")
                .hide();

        $("dt.question")
                .click(function () {
                    $(this)
                        .parent()
                        .find("dd.answer")
                        .slideToggle();
                });
    });

&lt;dl&gt;
    &lt;dt class="question"&gt;
        &lt;a id="q1"&gt;&lt;/a&gt;
        Question 1
    &lt;dd class="answer" style="display: none;"&gt;
        Answer 1
    &lt;/dd&gt;
&lt;/dl&gt;
&lt;dl&gt;
    &lt;dt class="question"&gt;
        &lt;a id="q2"&gt;&lt;/a&gt;
        Question 2
    &lt;dd class="answer" style="display: none;"&gt;
        Answer 2
    &lt;/dd&gt;
&lt;/dl&gt;
&lt;dl&gt;
    &lt;dt class="question"&gt;
        &lt;a id="q3"&gt;&lt;/a&gt;
        Question 3
    &lt;dd class="answer" style="display: none;"&gt;
        Answer 3
    &lt;/dd&gt;
&lt;/dl&gt;
</code></pre>
