js冲突问题,搞定马上结贴给分~!十万分感谢
第一个JS
$(document).ready(function(){
$('.son_ul').hide(); //初始ul隐藏
$('.select_box span').hover(function(){ //鼠标移动函数
$(this).parent().find('ul.son_ul').slideDown(); //找到ul.son_ul显示
$(this).parent().find('li').hover(function(){$(this).addClass('more')},function(){$(this).removeClass('more')}); //li的hover效果
$(this).parent().hover(function(){},
function(){
$(this).parent().find("ul.son_ul").slideUp();
}
);
},function(){}
);
$('ul.son_ul li').click(function(){
$(this).parents('li').find('span').html($(this).html());
$(this).parents('li').find('ul').slideUp();
});
}
);
function Scroll(obj, h, s) {
var h = h || 100;
var s = s || 1.2;
var obj = typeof(obj)=="string"?document.getElementById(obj):obj;
if(obj == undefined){return false;}
var status = obj.getAttribute("status")==null;
var oh = parseInt(obj.offsetHeight);
obj.style.height = oh;
obj.style.display = "block";
obj.style.overflow = "hidden";
if(obj.getAttribute("oldHeight") == null)
{
obj.setAttribute("oldHeight", oh);
}else
{
var oldH = Math.ceil(obj.getAttribute("oldHeight")); }
var reSet = function() {
if(status)
{
if(oh < h)
{
oh = Math.ceil(h-(h-oh)/s);
obj.style.height = oh+"px";
}
else
{
obj.setAttribute("status",false);
window.clearInterval(IntervalId);
}
}
else
{
obj.style.height = oldH+"px";
obj.removeAttribute("status");
window.clearInterval(IntervalId);
}
}
var IntervalId = window.setInterval(reSet,10); return status;
}
var $ = function(id){return document.getElementById(id)};
var number = document.getElementsByTagName('div');
window.onload= function()
{
for(var i = 0;i < number.length ;i++)
{
(function(i)
{
$('test'+i+'').onclick = function()
{
Scroll('test'+i+'',this.scrollHeight,1.2);
}
}
)(i);
}
}
<div id="main_box" class="soso">
<ul>
<li class="select_box">
<span>搜全部</span>
<ul class="son_ul">
<li>找商户</li>
<li>找优惠</li>
<li>找商品</li>
</ul>
</li>
</ul>
</div>
$变量改成别的,如$$
[解决办法]
var $ = function(id){return document.getElementById(id)}; 这个和你的jquery冲突了