【发布时间】:2017-07-06 14:22:56
【问题描述】:
这里我将 {{id}} 传递给 hide_show(...) javascript 函数
{% for stock in part_temp.part_stock_set.all %}
{% with id="list"|concatenate:stock.id %}
<div id="{{ id }}">
{{ stock.entry_date}}
</div>
<button type="button" onclick="hide_show({{ id }})">edit</button>
<br>
{{ id }}
在 {% endwith %} {{ id }} 上方显示正确,但未调用 hide_show 函数,但仅在 {{ stock.id }} 传递给它时调用它。 连接过滤器只是连接并返回一个字符串。
<script type="text/javascript">
function hide_show(temp) {
document.getElementById(temp).style.display='none';
window.alert(temp);
}
</script>
【问题讨论】:
标签: javascript django django-templates