我想在用户单击链接/按钮后加载(或可见)HTML/ASP.NET 电子邮件表单。我已经使用了这段代码,但它不起作用:
<script type="text/javascript">
$(document).ready(function () {
$("#imgMail").click(function (htm) {
$.get("mailform.html"),
$("#mailForm").append(htm)); //i have tryed also with .html() function.
});
});
</script>
#imgMail 是链接/按钮的 ID,#mailForm 是加载内容的 DIV 元素的 ID。
我该如何解决这个问题? 附言元素不在表单标签中。
谢谢。
最佳答案
用这个..
<script type="text/javascript">
$(document).ready(function () {
$("#imgMail").click(function() {
$.get("mailform.html",function(data){
$("#mailForm").append(data);
});
});
});
</script>
关于javascript - jQuery AJAX : load HTML into DIV element after click,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12581237/