我的脚本文件中有jquery函数:
function modalpopup(id)
{
var searchid = "\"#" + id + "\"";
var element = $(searchid );
element.dialog({
height: 340,
width: 500,
modal: true
});
}
在我的asp.net 2.0文件中,我有以下内容:
<a id="_ctl0_MainContentPlaceHolder_DataGrid1__ctl2_HyperLinkInfo" onclick="modalpopup('_ctl0_MainContentPlaceHolder_DataGrid1__ctl2_details10')">
<img src="../Images/info_icon.PNG" border="0" /></a>
<div id="_ctl0_MainContentPlaceHolder_DataGrid1__ctl2_details10" title="Dialog Title"
style="display: none;">
<center>
<table class="table_class" cellspacing="1" cellpadding="2" rules="all" border="1"
id="_ctl0_MainContentPlaceHolder" style="border-style: None; height: 24px; width: 800px;
font-size: 16px;">
<tr class="table_header_class" style="color: DarkGray; font-weight: bold; font-size: 16px;
white-space: nowrap">
<td style="white-space: nowrap">
customer details </td>
</tr>
</table>
</center>
</div>
它看起来像一个简单的jquery作业来找到div元素,但是jquery结果是null !!
我在这里做错了什么? 我的html代码中没有错误格式
请帮忙
答案 0 :(得分:1)
<html>
<head>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script>
function modalpopup(id)
{
alert(id);
var searchid = id;
var element = $("#"+searchid );
element.dialog({
height: 340,
width: 500,
modal: true
});
}
</script>
</head>
<body>
<a href="javascript:void(0);" id="_ctl0_MainContentPlaceHolder_DataGrid1__ctl2_HyperLinkInfo" onclick="modalpopup('_ctl0_MainContentPlaceHolder_DataGrid1__ctl2_details10');">
<img src="../Images/info_icon.PNG" border="0" /></a>
<div id="_ctl0_MainContentPlaceHolder_DataGrid1__ctl2_details10" title="Dialog Title"
style="display: none;">
<center>
<table class="table_class" cellspacing="1" cellpadding="2" rules="all" border="1"
id="_ctl0_MainContentPlaceHolder" style="border-style: None; height: 24px; width: 800px;
font-size: 16px;">
<tr class="table_header_class" style="color: DarkGray; font-weight: bold; font-size: 16px;
white-space: nowrap">
<td style="white-space: nowrap">
customer details </td>
</tr>
</table>
</center>
</div>
</body>
</html>
这很有效:
答案 1 :(得分:0)
这将解决问题
function modalpopup(id) {
var element = $('#'+id);
element.dialog({
height: 340,
width: 500,
modal: true
});
}
答案 2 :(得分:0)
试试这个:
function modalpopup(id)
{
$("#"+id).dialog({
height: 340,
width: 500,
modal: true
});
}