我在 HTML 模板中有一些 JS。如何按语法计算某个值,将其存储在变量中,然后将其用作元素的 ID?它现在不工作。谁能帮我弄清楚我做错了什么?
if (key == "down"){
var tri_id = "triangle" + status_JSON['down'][1];
document.getElementById(tri_id).innerHTML = "<img class='voting' src='images/vote_grey.png'></img>";
document.getElementById(status_JSON['down'][1]).innerHTML = status_JSON["down"][0];
}
DOM 是:
<script type="text/javascript">
var triangle_id = "triangle" + "{{each[1].key()}}";
</script>
<div class='votes_div'>
<table id="votes_table">
<tr>
<td>
<a href='javascript:registerVote("{{each[1].key()}}")'>
<span id=triangle_id title='vote if you think this review is helpful'><img class='voting' src='../../../../images/vote_grey.png'></img></span>
</a>
</td>
</tr>
对不起,我是初学者!