rendered paste body<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html> <head> </head> <body> <script type="text/javascript" src="jquery-1.3.2.min.js"></script> <script type="text/javascript"> function make(tabs, on_click, on_hover_in, on_hover_out) { for(i in tabs) { var e = $(tabs[i]); e.attr('selected', 'false'); e.hover(function() { on_hover_in($(this)); }, function() { if ('false' == $(this).attr('selected')) on_hover_out($(this)); }); e.click(function() { for (i in tabs) { $(tabs[i]).attr('selected', 'false'); on_hover_out($(tabs[i])); } $(this).attr('selected', 'true'); on_hover_in($(this)); }); } $(tabs[0]).click(); } function h1(e) { e.css('background-color', 'red'); } function h2(e) { e.css('background-color', 'white'); } function h3(e) { alert(e); } $(document).ready(function() { var btns = ['#btn1', '#btn2', '#btn3']; make(btns, h3, h1, h2); }); </script> <div> <a href="#" id="btn1">jeden</a> <a href="#" id="btn2">dwa</a> <a href="#" id="btn3">trzy</a> </div> </body></html>