$(document).ready(function () { odd = { "background": "none" }; //奇数样式 even = { "background": "#f3f3f3" }; //偶数样式 odd_even(".gys_xq", odd, even); }); function odd_even(id, odd, even) { $(id).find("dl").each(function (index, element) { if (index % 2 == 1) $(this).css(even); else $(this).css(odd); }); }