Problem with JQuery onClick Event
<p>Please someone let me know what the problem is here, it just wont work :(</p>

<pre><code>function openLightbox(url) {
    alert('test');
    $('#Lightbox').attr('href', url);
    $('#Lightbox').click();
}

openLightbox('test.asp?url=12313');
</code></pre>

<p>For some reason it will not work. When I change it to this ... it works!</p>

<pre><code> $('#Lightbox').attr('href', 'manuallyseturl.asp');
 $('#Lightbox').click();
</code></pre>

<p>Has anyone got any ideas?!</p>

<p>If I have an alert before the function I can see the alert, but for some reason the URL does not change. Just to give you a bit of background the onclick event triggers a lightbox which then opens.</p>

<p>Odly when I have Javascript ready before any code, it says "Unexpected end of input"</p>

<pre><code>$(document).ready(function(){   
   alert('test');
}
</code></pre>

<hr>

<p>ANSWER:</p>

<p>I figured it out, I needed to use Javascript onready in the function! For some reason if I didnt use this it would just error! How annoying!</p>
