我想首先感谢任何能够帮助我压缩这段Javascript/jQuery代码的人。凝聚Javascript/jQuery代码
jQuery(function() {
jQuery('#pitem-1').click(function(e) {
jQuery("#image-1").lightbox_me({centered: true, onLoad: function() {
jQuery("#image-1").find("input:first").focus();
}});
e.preventDefault();
});
jQuery('#pitem-2').click(function(e) {
jQuery("#image-2").lightbox_me({centered: true, onLoad: function() {
jQuery("#image-2").find("input:first").focus();
}});
e.preventDefault();
});
jQuery('#pitem-3').click(function(e) {
jQuery("#image-3").lightbox_me({centered: true, onLoad: function() {
jQuery("#image-3").find("input:first").focus();
}});
e.preventDefault();
});
jQuery('table tr:nth-child(even)').addClass('stripe');
});
基本上每个#pitem-ID在弹出窗口中打开相同的#图像ID。
再次感谢任何可以帮助的人。
杰克
是什么阻止你使用一个循环? – Claudiu 2012-04-28 00:56:48
首先用$替换jQuery。 – alt 2012-04-28 00:58:15
我使用jQuery而不是$来防止与Prototype冲突。 – 2012-04-28 11:49:21