Hi

you cannot have multiple ids ids are unique you need to use a class name
instead

.
<img src="button.jpg" alt="button"  border="0" id="myButton"
class="hoverbutton"/>
end loop

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

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




On Tue, Jun 9, 2009 at 12:56 PM, simon <si...@uvfx.tv> wrote:

>
> 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
>



-- 
Armand Datema
CTO SchwingSoft

Reply via email to