Jquery只处理第一个函数/代码块
Jquery only processing first function/block of code
我有一个包含三个不同的jquery代码片段的页面,它们都做不同的事情。问题是,当它们都在页面上时,只有第一个有效。我已经改变了顺序,不管代码片段是什么,只有第一个有效。是否有一个内部的jquery冲突我错过了?
我代码:<script type="text/javascript">
jQuery(document).ready( function() {
$("#main-menu li").mouseenter(function() {
$(this).find("ul").fadeIn();
}).mouseleave(function(){
$(this).parent().find("ul").fadeOut();
});
jQuery( ".text-resize a" ).textresizer({
target: ".content",
type: "fontSize",
sizes: [ "12px", "16px" ],
selectedIndex: 0
});
jQuery( ".text-resize a" ).textresizer({
target: ".title",
type: "fontSize",
sizes: [ "11px", "16px" ],
selectedIndex: 0
});
jQuery( ".text-resize a" ).textresizer({
target: ".show-more",
type: "fontSize",
sizes: [ "12px", "16px" ],
selectedIndex: 0
});
jQuery( ".text-resize a" ).textresizer({
target: "#footer",
type: "fontSize",
sizes: [ "12px", "16px" ],
selectedIndex: 0
});
jQuery( ".text-resize a" ).textresizer({
target: ".copyright",
type: "fontSize",
sizes: [ "11px", "16px" ],
selectedIndex: 0
});
$(".slidetabs").tabs(".images > div", {
// enable "cross-fading" effect
effect: 'fade',
fadeOutSpeed: "2000",
// start from the beginning after the last tab
rotate: true
// use the slideshow plugin. It accepts its own configuration
}).slideshow( {autoplay: true, interval:3000});
});
</script>
谢谢
我假设你正在使用这个textResizer插件。你真的应该使用type="cssClass"
,如果你要针对不同大小的页面的不同部分。
jQuery( ".text-resize a" ).textresizer({
target: "body",
type: "cssClass",
sizes: [ "size1", "size2" ],
selectedIndex: 0
});
你的CSS看起来像
body.size1 .content { font-size: 12px;}
body.size2 .content { font-size: 16px;}
body.size1 .title { font-size: 11px;}
body.size2 .title { font-size: 16px;}
body.size1 .show-more { font-size: 12px;}
body.size2 .show-more { font-size: 16px;}
body.size1 #footer { font-size: 12px;}
body.size2 #footer { font-size: 16px;}
body.size1 .copyright { font-size: 11px;}
body.size2 .copyright { font-size: 16px;}
最好将相同的
的CSS组合在一起。body.size1 .title,
body.size1 .copyright { font-size: 11px;}
body.size1 .content,
body.size1 #footer,
body.size1 .show-more { font-size: 12px;}
body.size2 .content,
body.size2 .title,
body.size2 .show-more,
body.size2 #footer,
body.size2 .copyright { font-size: 16px;}
相关文章:
- 如何将函数包装在函数中以避免代码重复
- 从var向代码隐藏函数传递值
- Angularjs代码未在匿名函数中运行
- 输入字段验证的键代码函数在chrome中没有按预期工作
- 将两个云代码函数合并为一个函数
- 这个JavaScript代码(函数)有什么问题
- 解析之前保存()云代码函数不起作用
- 是否可以从云中调用 Parse 定义的云代码函数
- chrome、firefox、ie11中的基本html代码函数,但不是ie9
- 未定义从php代码函数调用javascript函数
- 云代码函数运行两次
- 反转jQuery代码函数
- Javascript代码——函数ToppingsWanted()有什么问题?
- 在javascript中反映本机代码函数参数
- 如何使用Javascript SDK调用带有参数的云代码函数
- 从一个云代码函数返回多个值
- 在AngularJs中使用遗留代码函数
- Javascript代码函数解释
- JavaScript和Cloud代码函数,共享相同的var
- 解析从另一个云代码函数中调用云代码函数的Javascript