[英]Bootstrap button onclick not working
I have a node express app using EJS. 我有一个使用EJS的节点快速应用程序。
I have a button: 我有一个按钮:
<button type="button" class="btn btn-success" onclick="exportWithObjectId('<%= user.id %>')">Export to csv</button>
and a script: 和一个脚本:
<script type="text/javascript">
function exportWithObjectId(objectId) {
console.log("objectID inside .ejs: " + objectId);
}
</script>
in my .ejs file but when I click there is no log. 在我的.ejs文件中,但是当我单击时没有日志。 Any idea what I'm doing wrong?
知道我在做什么错吗?
Remove document.
移除
document.
from your function call: 从您的函数调用中:
onclick="exportWithObjectId('<%= user.id %>')">
Or, replace it with window.
或者,将其替换为
window.
: :
onclick="window.exportWithObjectId('<%= user.id %>')">
function exportWithObjectId(objectId) { console.log("objectID inside .ejs: " + objectId); alert('Just to be sure! objectID inside .ejs: ' + objectId); }
<button type="button" class="btn btn-success" onclick="exportWithObjectId('<%= user.id %>')">Export to csv</button>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.