任何人都可以告诉我这行有什么问题吗?
模板:
<c:forEach items="${templateList}" var ="temp">
<td>
<button onclick = "edit(${temp.id});" data-target="#myModal1" data-toggle="modal" title="Edit" class="btn btn-success btn-sm"><i class="fa fa-edit"></i>Edit</button>
</td>
<td>
<button data-target="#myModal2" title="Attach Link" data-toggle="modal" class="btn btn-success btn-sm"><i class="fa fa-paperclip"></i></button>
</td>
<td>
<button data-target="" data-toggle="modal" title="duplicate" class="btn btn-success btn-sm"><i class="fa fa-copy"></i></button>
</td>
</c:forEach>
以及此功能
<script>
function edit(id){
$.get("get/" + id,function(result){
$("#myModal1").html(result);
alert("dnrbufevc ");
});
}
</script>
答案 0 :(得分:1)
将onClick
的模板更改为以下
<button onclick = "edit('${temp.id}')" data-target="#myModal1" data-toggle="modal" title="Edit" class="btn btn-success btn-sm"><i class="fa fa-edit"></i>Edit</button>
确保'${temp.id}'
周围有单引号,以便javascript将其视为字符串文字。