我有我的 mainpage.aspx 和我的 mainDetails.ascx
/*As well as this javascript:*/
$(document).ready(function() {
$("#modal-close").click(function() {
$("#modal-content, #modal-background, #modal-close").toggleClass("active");
});
$("#keywordSelection").click(function() {
alert('hit');
});
});
/*mainDetails.ascx is an `asp:UpdatePanel` this contains the following javascript:*/
function jsModal() {
$("#keywordSearch").click(function() {
//alert('hi');
$("#modal-content, #modal-background, #modal-close").toggleClass("active");
//$("#modal-content").$("divTestVal").append.html
var html = $("#modal-content").next("#divTestVal").html();
alert(html);
});
}
<!-- mainpage.aspx is a web form that contains the following:-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="modal-background"></div>
<div id="modal-content">
<input type="button" id="modal-close" value="Close Modal Window" />
<br />
<div id="divTestVal">
[Append Values Here!]
</div>
<br />
<input type="button" id="keywordSelection" value="Selector!" />
</div>
我需要的是一种从模态中填充和读取值的方法。现在 html 变量返回 null
。
如何从模态中获取[Append Values Here!]
值?
最佳答案
我找到了一种方法。
在 mainDetail.ascx javascript 中我添加了以下内容:
$('#modal-content div').each(function (index) {
alert($(this).text());
$(this).html("updated text now");
});
这不仅循环遍历 mainpage.aspx 上模态窗口中的每个 div,而且还更新 div 中的文本值。
关于javascript - 更新面板和模式窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28815905/