jQuery - change function from click event to page load
<p>I have a jQuery code inside an ascx that takes a cell content from a gridview and manipulate it, then write it to other cell.</p>

<p>It is activated by a click on the gridview row.</p>

<p>(Each row has a 1st cell with Word file name. The user clicks on a row - jQuey takes the file name in first cell and changes the extension to flv/mp3 - checks if there is a file with the new name - if there is a file it creates an image link to that file)
I worked hard on this code but now the client want that the event (meaning that the image links that show if there is a file with the flv/mp3 ) will occur on page load.</p>

<p>I do not want to write all again and think there should be a way to just change the click event. </p>

<p>The problem is I am not very efficient with jQuery :)
Can some jQuery hotshot help on this?</p>

<p>Here is the code (I am not proud with this code but it does the job): </p>

<pre><code>    &lt;script type="text/javascript"&gt;
    jQuery(function() {
        jQuery(".SearchResultsGV &gt; tbody &gt; tr:not(:has(table, th))")
            .css("cursor", "pointer")
            .one("click", function(e) {

                var jQuerycell = jQuery(e.target).closest("td");


                var jQuerycurrentCellText = jQuerycell.text();
                var jQueryleftCellText = jQuerycell.prev().text();
                var jQueryrightCellText = jQuerycell.next().text();
                var jQuerycolIndex = jQuerycell.parent().children().index(jQuerycell);
                var jQuerycolName = jQuerycell.closest("table")
                    .find('th:eq(' + jQuerycolIndex + ')').text();
                //Check media 1
                jQuery.ajax({
                    url: 'http://dtora.org.il/Portals/0/Shiurim/' + jQuerycell.parent().children().first().text().replace('.doc', '.mp3'),
                    type: 'HEAD',
                    error:
                        function() {
                            //do something depressing
                            jQuery(jQuerycell.parent().children().last()).append("&lt;img src=http://dtora.org.il/Portals/0/images/noFiles.png /&gt;");

                        },
                    success:
                        function() {
                            //do something cheerful :)
                            var jQueryMedia1Name = ('&lt;a href=http://dtora.org.il/Portals/0/Shiurim/' + jQuerycell.parent().children().first().text().replace('.doc', '.mp3') + '&gt;&lt;img class="soundFile" src=http://dtora.org.il/Portals/0/images/Music.png /&gt;&lt;/a&gt;')
                            jQuery(jQuerycell.parent().children().last()).append(jQueryMedia1Name);

                        }
                });
                //Check media 2
                jQuery.ajax({
                    url: 'http://dtora.org.il/Portals/0/Shiurim/' + jQuerycell.parent().children().first().text().replace('.doc', '.flv'),
                    type: 'HEAD',
                    error:
                        function() {
                            //do something depressing
                            jQuery(jQuerycell.parent().children().last()).append("&lt;img src=http://dtora.org.il/Portals/0/images/noFiles.png /&gt;");

                        },
                    success:
                        function() {
                            //do something cheerful :)
                            var jQueryMedia2Name = ('&lt;a href=http://dtora.org.il/Portals/0/Shiurim/' + jQuerycell.parent().children().first().text().replace('.doc', '.flv') + '&gt;&lt;img class="videoFile" src=http://dtora.org.il/Portals/0/images/Video.png /&gt;&lt;/a&gt;')
                            jQuery(jQuerycell.parent().children().last()).append(jQueryMedia2Name);

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