<html>
<script src="http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js"></script>
<body>
<p id="ppp" style="background-color:yellow">asasasa</p>
</body>
<script>
function downloadUploadFile(fileid) {
console.log(fileid); // <p id="123">...</p> 此处为何传进来是dom对象??
console.log(typeof fileid);// object??
}
function createNode(fileId, fileName) {
return $("<p id='id_" + fileId + "'> <a href='javascript:void(0)' onclick=downloadUploadFile(id_" + fileId + ");>下个载 " + fileName + "</p>");
}
var node = createNode('123', '槽边往事');
console.log(node); //[p#id_123]
$("#ppp").append(node);
</script>
</html>
如上代码,用js创建提供下载功能的节点,并绑定download事件,可是为何穿进去的参数是对象?而不是id_123
慕村225694
相关分类