Johannes Theile wrote:
> Hi,
> I came across jQuery, I thinks I might like it, but I'm unable to try it
> out.
> 
> I downloaded the uncompressed version and just c&p one of the examples from
> the Wiki. But nothing happens. I tried it with various browsers on two
> systems, but nothing works. So I thinks that I'm doing a general mistake.
> Maybe someone could check the code below.
> 
> #####
> <html>
> <head>
> <script type="text/javascript" src="jquery.js"></script>
> <script type="text/javascript">
> 
>       $("a").click(function(){
>       alert("Thanks for visiting!");
>       });
> 
> </script>
> </head>
> 
> <body>
>        # Do something! 
> </body>
> </html>
> #####
> 
> jQuery is in the same folder as my html page is.
> 
> Any help is appreciated.
> 
> Regards,
> Johannes


Johannes, you have to execute the examples after the DOM is ready. 
Otherwise a query like $('a') returns 0 elements (because at that time 
there no elements).

<script type="text/javascript">
$(document).ready(function() {
     $("a").click(function(){
     alert("Thanks for visiting!");
});
</script>

$(document).ready() attaches a function to be executed when the DOM is 
ready (which is earlier than the load event).

You will often see a shorter form for that:

$(function() {
     // do something with DOM
});


-- Klaus

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to