如何给innerHtml中的函数指定参数 20
有这样的代码:<script>....obj='tup';td.innerHTML='<inputtype=filename=card_uploadFile'+uploa...
有这样的代码:
<script>
....
obj = 'tup';
td.innerHTML = '<input type=file name=card_uploadFile'+upload_num+' style="margin-left:0px;font-size:100%;"> <a href=javascript:void(0) onclick=delete_upload()>删除附件</a>'
....
</script>
想把obj作为参数传递给函数delete_upload(),这个语句格式该怎么写呢?
是:delete_upload('+obj+')?
还是:delete_upload(obj)?
都说“为空或不是对象” 展开
<script>
....
obj = 'tup';
td.innerHTML = '<input type=file name=card_uploadFile'+upload_num+' style="margin-left:0px;font-size:100%;"> <a href=javascript:void(0) onclick=delete_upload()>删除附件</a>'
....
</script>
想把obj作为参数传递给函数delete_upload(),这个语句格式该怎么写呢?
是:delete_upload('+obj+')?
还是:delete_upload(obj)?
都说“为空或不是对象” 展开
1个回答
展开全部
假设upload_num=1
delete_upload(obj)
相当于
<input type=file name=card_uploadFile1 style="margin-left:0px;font-size:100%;"> <a href=javascript:void(0) onclick=delete_upload(obj)>删除附件</a>
obj前面已经定义过了,所以没错
相当于
<input type=file name=card_uploadFile1 style="margin-left:0px;font-size:100%;"> <a href=javascript:void(0) onclick=delete_upload('tup')>删除附件</a>
delete_upload('+obj+')
相当于
<input type=file name=card_uploadFile1 style="margin-left:0px;font-size:100%;"> <a href=javascript:void(0) onclick=delete_upload(tup)>删除附件</a>
tup是未定义的变量,错误
delete_upload(obj)
相当于
<input type=file name=card_uploadFile1 style="margin-left:0px;font-size:100%;"> <a href=javascript:void(0) onclick=delete_upload(obj)>删除附件</a>
obj前面已经定义过了,所以没错
相当于
<input type=file name=card_uploadFile1 style="margin-left:0px;font-size:100%;"> <a href=javascript:void(0) onclick=delete_upload('tup')>删除附件</a>
delete_upload('+obj+')
相当于
<input type=file name=card_uploadFile1 style="margin-left:0px;font-size:100%;"> <a href=javascript:void(0) onclick=delete_upload(tup)>删除附件</a>
tup是未定义的变量,错误
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询