jQuery Event only firing for first named element

events, jquery

Solution

$(function(){
  $("#formID").validationEngine(); // don't forget your semi-colons
  $(".mylink").click(function(e){  // ID's should be unique, use classes instead
    e.preventDefault();
    $.ajax({ url: $(this).attr("href") });
    $(this).parent().parent().fadeOut("slow"); // refer to this as 'this'
  });
});

Problem

I have hyperlinks, all are named 'mylink'. They should all fire the same event, but only the first element named 'mylink' actually fires. My code is as follows: ``` $(document).ready(function() { $("#formID").validationEngine() $('#mylink').click(function(e){ var goto = $(this).attr('href'); //get the url $.ajax({ url: goto }); //execute the href e.preventDefault(); //prevent click $('#mylink').parent().parent().fadeOut("slow"); }); }) ``` Where am I going wrong?

Original source