我试图有一个图标,当单击时,触发一个 jQuery 对话框,显示特定于被单击项目的消息。因为我是 jQuery 的新手,所以我绝对没有运气。有人可以告诉我我做错了什么吗?
ASP MVC View 中的代码部分
<td>
@if (!String.IsNullOrWhiteSpace(item.Notes))
{
<span id="notes" onclick='GetNotes(@id);'>
<img src="@Url.Content("~/Content/images/magnify.gif")" alt="Show Notes" />
</span>
}
<div id="@id" style="display:none;">
@Html.DisplayFor(modelItem => item.Notes)
</div>
</td>
jQuery 代码:
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<script src="@Url.Content("~/Scripts/jquery.tablesorter.min.js")" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#thetable").tablesorter();
}
);
function GetNotes(id) {
$(function GetNotes() {
$("#" + id + "\"").dialog();
});
}
</script>
编辑
onlick 方法名称之前包含错误。多了一个‘)’。
最佳答案
在这个 GetNotes
函数中,有一些相当损坏的 JavaScript。尝试这样:
function GetNotes(id) {
$('#' + id).dialog();
}
还可以在浏览器中观察 JavaScript 调试控制台。它会向您显示错误。
关于jquery - 让 jQuery 对话框在 onclick 上工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14388755/