a.onclick=addEmotion(num);
这里需要闭包a.onclick=function(){addEmotion(num);}<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="jquery-1.3.2.min.js"></script>
<script type="text/javascript">
function CreateImg(num)
{
var a=document.createElement("a");
a.setAttribute("href","#");
a.onclick=function(){addEmotion(num)};
a.innerHTML="ccc";
document.getElementById("a").appendChild(a);
return a;
}function addEmotion(num)
{
alert(num)
}
window.onload=function(){CreateImg(3)}
</script>
<title>无标题文档</title>
</head><body><div id="a"></div></body>
</html>
这里需要闭包a.onclick=function(){addEmotion(num);}<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="jquery-1.3.2.min.js"></script>
<script type="text/javascript">
function CreateImg(num)
{
var a=document.createElement("a");
a.setAttribute("href","#");
a.onclick=function(){addEmotion(num)};
a.innerHTML="ccc";
document.getElementById("a").appendChild(a);
return a;
}function addEmotion(num)
{
alert(num)
}
window.onload=function(){CreateImg(3)}
</script>
<title>无标题文档</title>
</head><body><div id="a"></div></body>
</html>
{
var a=document.createElement("a");
a.setAttribute("href","#");
(
function(o,m){
o.onclick=function(){addEmotion(m);}
}
)(a,num);
a.innerHTML="ccc";
document.getElementById("a").appendChild(a);
return a;
}
{
getEditor().focus();
getEditor().value+="[face"+addr+"]";
}