javascript - scriptaculous: onmouseover /onmouseout for several ids and flickering problem -


hi want have same event happen different images , write code line 1 time in .js file. should basic can't find easy guide.

this 1 sample of code, , have @ least 2 times per page:

<ul class="car-slide">         <li onmouseover="$('fp1').fade( {duration:.2, from:1, to:0.8 }); return false;" onmouseout="$('fp1').appear( {duration:.2}); return false;"><img src="{{skin url='myimage1'}}" id="fp1"></li>         <li onmouseover="$('fp2').fade( {duration:.2, from:1, to:0.8 }); return false;" onmouseout="$('fp2').appear( {duration:.2}); return false;" style="border-left:1px solid #000;border-right:1px solid #000;"><img src="{{skin url='myimage2'}}" id="fp2"></li>         <li onmouseover="$('fp3').fade( {duration:.2, from:1, to:0.8 }); return false;" onmouseout="$('fp3').appear( {duration:.2}); return false;"><img src="{{skin url='myimage3'}}" id="fp3"></li>     </ul> 

so it's 3 times same in list, , have twice. don't know how syntax in js, , how refer in html.

also if know why second li has flickering problems, when going fast on when first , third 1 have no problems @ great (might related additional styling still strange)

try this

$$('.car-slide')[0].select('.carsliderfade').each(function(el){     el.observe('mouseover', function(){ el.fade( {duration:.2, from:1, to:0.8 }); });     el.observe('mouseout', function(){ el.appear( {duration:.2}); }) }) 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -