2014-01-29 74 views
0

多个颜色框其实我优化我的网站和我有颜色框魔女一些问题让我打电话给太多的脚本组相同的参数

我确实有这个

的jQuery(“a.Miro1”)。 colorbox({innerWidth:900,innerHeight:800, iframe:true}); jQuery('a.sofia1')。colorbox({innerWidth:900,innerHeight:800, iframe:true}); jQuery('a.MP13')。colorbox({innerWidth:900,innerHeight:800, iframe:true}); jQuery('a.iframeLion')。colorbox({innerWidth:900, innerHeight:800,iframe:true}); jQuery('a.ddopa1')。colorbox({innerWidth:900,innerHeight:800, iframe:true}); jQuery('a.AppEnt1')。colorbox({innerWidth:900,innerHeight:800, iframe:true}); jQuery('a.smg1')。colorbox({innerWidth:900,innerHeight:800, iframe:true}); jQuery('a.almpn1')。colorbox({innerWidth:900,innerHeight:800, iframe:true}); jQuery('a.kickboxing1')。colorbox({innerWidth:900, innerHeight:800,iframe:true}); jQuery('a.saw01')。colorbox({innerWidth:900,innerHeight:800, iframe:true}); jQuery('a.sanggene1')。colorbox({innerWidth:900, innerHeight:800,iframe:true}); jQuery('a.Ucreed1')。colorbox({innerWidth:900,innerHeight:800, iframe:true}); jQuery('a.dior1')。colorbox({innerWidth:900,innerHeight:800, iframe:true}); jQuery('a.Client')。colorbox({innerWidth:900,innerHeight:800, iframe:true});

如何将所有这一切归为一类?它们都具有相同的参数,只是不同的链接

感谢

回答

0

试试这个:

jQuery('a.Miro1, a.sofia1, a.MP13, a.iframeLion, a.ddopa1, a.AppEnt1, a.AppEnt1, a.smg1, a.almpn1, a.kickboxing1, a.saw01, a.sanggene1, a.Ucreed1, a.dior1, a.Client').colorbox({ 
    innerWidth:900, 
    innerHeight:800, 
    iframe:true 
}); 

或者,我会建议一个共同的类添加到所有的彩盒元素,只做一次。像:

jQuery('a.colorBoxElms').colorbox({ 
    innerWidth:900, 
    innerHeight:800, 
    iframe:true 
}); 
0

我怎能组在一个所有这一切吗?他们都有相同的参数 ,只是不同的链接

什么参数?您可以为所有链接添加额外的class,然后使用:

jQuery('.cbox').colorbox({ innerWidth:900, innerHeight:800, iframe:true }); 

OR组选择:

jQuery('a.Miro1, a.sofia1, a.MP13, a.iframeLion, a.ddopa1') 
    .colorbox({ innerWidth:900, innerHeight:800, iframe:true }); 
0

只是仰望未压缩的版本,并更改​​默认的js文件,或预先定义的选项`

var cboxOptions = { innerWidth: 900, innerHeight:800, iframe:true } 
jQuery('a.Miro1').colorbox(cboxOptions); 
... 
... 

还是最好的,因为我看到所有的选项都是有的,为什么不

jQuery('a.Miro1,a.sofia1,....').colorbox({innerWidth:900, innerHeight:800, iframe:true}); 

或者只是为所有链接添加一个公共类,您确定知道您可以为每个元素添加更多类...

<a class="Miro1 jqcbox">click me</a> 
<a class="sofia1 jqcbox">click me</a> 

..然后你只需要调用颜色框一次的jQuery( 'a.jqcbox')颜色框。(...

+0

问题太新鲜的问题;)我看到3个人建议你bassicaly相同...向所有链接添加普通类... – Peminator