我在得到的元素上添加鼠标移入事件,可是无法看到结果,我技穷啦。
var zidiv = document.getElementById(objs.root[i].systermInfoId);
zidiv.onmouseover(function(){
alert(666);
});
var zidiv = document.getElementById(objs.root[i].systermInfoId);
zidiv.onmouseover(function(){
alert(666);
});
alert(666);
};
这样写
window.onload = function(){a();ready();}
//表示当前高亮的节点
var highlightindex = -1;
var timoutId;
var childdiv;
var div;
function a(){
//alert(1);
}
function ready() {
var wordInput = $("#word");
var wordInputOffset = wordInput.offset();
//自动补全框最开始应该隐藏起来
$("#auto").hide().css("border","1px black solid").css("position","absolute")
.css("top",wordInputOffset.top + wordInput.height() + 5 + "px")
.css("left",wordInputOffset.left + "px").width(wordInput.width() + 3);
}function getProjectList(param){
$.post(
"../getJSONString/operation.do",
{
Action:"post",
method:"getSysJSONGString",
param:param
},
function(message){
// alert(message);
eval('var objs = ' + message);
if(objs.root.length!=0){
for(var i = 0; i<objs.root.length;i++){
alert(objs.root[i].systermInfoId + " " + objs.root[i].sysName);
div = document.getElementById("auto");
childdiv = document.createElement("div");
div.appendChild(childdiv);
childdiv.setAttribute("id", objs.root[i].systermInfoId);
document.getElementById(objs.root[i].systermInfoId).innerHTML = '<span id="sysName">'+objs.root[i].sysName+'</span>';
}
$("#auto").show();
var zidiv = document.getElementById(objs.root[i].systermInfoId);
zidiv.onmouseover=function(){
alert(666);
}
}else{
$("#auto").hide();
}
});
}
上面这句应该是dom对象,不知道能不能
zidiv.onmouseover=function(),
你既然用到jquery了,那就改成jquery的方式写嘛:
zidiv.mouseover(function(){});
$zidiv.bind("mouseover",function(){
alert("666");
});
var $zidiv = document.getElementById(objs.root[i].systermInfoId);改成
var $zidiv = $("#"+objs.root[i].systermInfoId);