<script>
function a(id)
{
var table = document.getElementById(id);
....
}
</script>
@{
//trying to rewrite the line "var table = document.getElementById(id)" at here
}
我可以知道这是否可行吗?服务器端有类似的代码吗?
最佳答案
如果您的问题是如何将服务端变量传递给 js 代码,则可以使用另一种方法来完成这项工作。 1.将服务端变量包装在html标签中,例如
在 html 代码中:
<input type="hidden" id="ssv" value="<% $id %>"/>
在js代码中:
var el = document.getElementById('ssy');
a(el.value);
关于javascript - 如何在 cshtml 服务器端代码中编写以下行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20917713/