My question is about syntax, or how to wite jquery code.
Is the example below ok? Putting all your code between document.ready
all your code with anonymous functions?

$(document).ready(function() {
   $('a.link1').click(function() {
      //code
   });
   $('a.link2').click(function() {
      //code
   });
   $('form.form1').submit(function() {
      //code
   });
   $('img.myPic1').css('border','solid 3px red');
});

or should i call named functions?

$(document).ready(function() {
   $('a.link1').click(clickFunction1());

   $('a.link2').click(clickFunction2());
});

function clickFunction1() {
   //code
}

function clickFunction2() {
    //code
}

I´ve heard that anonymous functions is a faster way??

thanks in advance

George

Reply via email to