I basically have several buttons that are created dynamically via a
db, so I can have 1 to 40 etc.
now at the moment I give each one a unique id and a hover code in the
loops. see below:

loops goes here..

<img src="button.jpg" alt="button"  border="0" id="myButton<?=
$newCode ?>" />
$(document).ready(function(){

$("#myButton<?=$newCode ?>").hover(
      function () {
        $(this).fadeTo('fast', .50);
      },
      function () {
        $(this).fadeTo('fast', 1.0);
      }
    );
});

end loop

this works fine but gives me a lot of jquery code as well for each as
i also have a click action after it, but thats another matter, what i
am after is if i just give it the same id as below  then i would like
only to have one hover code that would do the effect to all, but at mo
it will only do the effect to the first, any ideas?

loops goes here..
<img src="button.jpg" alt="button"  border="0" id="myButton"/>
end loop

So only this loops and i only need the code below once.

$(document).ready(function(){
$("#myButton").hover(
      function () {
        $(this).fadeTo('fast', .50);
      },
      function () {
        $(this).fadeTo('fast', 1.0);
      }
    );
});


Many thanks Si

Reply via email to