TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Javascript, AJAX, E4X (http://www.talkphp.com/javascript-ajax-e4x/)
-   -   jquery wont work for me :( (http://www.talkphp.com/javascript-ajax-e4x/3384-jquery-wont-work-me.html)

sarmenhb 09-27-2008 07:12 PM

jquery wont work for me :(
 
can someone explain why jquery wont work for me?
here is my page

http://www.gothostin.com/jquery/jquery.php

i am trying the tutorial on this page
Tutorials:How jQuery Works - jQuery JavaScript Library

and when i click on the link nothing happends :(

Salathe 09-27-2008 07:29 PM

Your code will execute as soon as the browser sees it, but at that time there are no <a> elements to attach the click function to! You need to wait until the HTML document is all downloaded to safely attach event handlers like this.

JavaScript Code:
jQuery(function(){

  $("a").click(function(event){
    alert("As you can see, the link no longer took you to jquery.com");
    event.preventDefault();
  });

});

sarmenhb 09-27-2008 08:52 PM

thanks alot :)


All times are GMT. The time now is 10:52 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0