在这个网站上,我有 2 种 jquery 用法,一种用于“任何 slider ”,另一种用于隐藏显示的切换。
如果我删除切换器到 jquery 的链接, slider 可以工作,但切换器不会...这是切换器的 jquery 的链接。
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.js"></script>
有谁知道我怎样才能让他们既工作又玩得开心?
谢谢
完整的代码是这样的:
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.js"></script>
<script>
$(document).ready(function() {
$('.nav-toggle').click(function(){
//get collapse content selector
var collapse_content_selector = $(this).attr('href');
//make the collapse content to be shown or hide
var toggle_switch = $(this);
$(collapse_content_selector).toggle(function(){
if($(this).css('display')=='none'){
toggle_switch.html('Learn More');//change the button label to be 'Show'
}else{
toggle_switch.html('Condense');//change the button label to be 'Hide'
}
});
});
});
</script>
最佳答案
不要加载两个不同的 javascript 库版本,只需要一个。
关于javascript - jquery的两种用法相互冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18470793/