我有我的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!]值?
发布于 2015-03-02 18:11:47
我找到了一种方法。
在mainDetail.ascx javascript中,我添加了以下内容:
$('#modal-content div').each(function (index) {
alert($(this).text());
$(this).html("updated text now");
});这个循环不仅在mainpage.aspx的模态窗口中遍历每个div,而且还更新div中的文本值。
https://stackoverflow.com/questions/28815905
复制相似问题