JQuery code not working
<p>Why is the following code giving an exception?</p>

<pre><code>function SetText(index, text) {
            try {
                $('p')[index].innerHTML = text;
            }
            catch (ex) {
                alert(ex);
            }
        }

        $(document).ready(SetText(2, 'Damn'));
</code></pre>

<p>the exception is:</p>

<pre><code>TypeError: $('p')[index] is undefined
</code></pre>

<p>This is my code file:</p>

<pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SelectingFromAnElementGroup.aspx.cs" Inherits="JQuery_Intellisence_Test.SelectingFromAnElementGroup" %&gt;

&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

&lt;html xmlns="http://www.w3.org/1999/xhtml" &gt;
&lt;head runat="server"&gt;
    &lt;title&gt;&lt;/title&gt;
    &lt;script src="Javascript/jquery-1.3.2.js" type="text/javascript"&gt;
        /// &lt;reference path="jquery-1.3.2-vsdoc.js" /&gt;
    &lt;/script&gt;
    &lt;script type="text/javascript"&gt;
        function SetText(index, text) {
            try {
                $('p')[index].innerHTML = text;
            }
            catch (ex) {
                alert(ex);
            }
        }

        $(document).ready(SetText(2, 'Damn'));
    &lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;form id="form1" runat="server"&gt;
        &lt;div&gt;
            &lt;p&gt;This is 1st Paragraph&lt;/p&gt;
            &lt;p&gt;This is 2nd Paragraph&lt;/p&gt;
            &lt;p&gt;This is 3rd Paragraph&lt;/p&gt;
            &lt;p&gt;This is 4th Paragraph&lt;/p&gt;
            &lt;p&gt;This is 5th Paragraph&lt;/p&gt;
        &lt;/div&gt;
    &lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
