I use the Viusal Studio 2015 and IE Browser to debug 。
First I click the hyperlink "AAA",the trace debug enter the function '$("#HrefBtn_1").click(function ()' successfully
,and then ajax html response the "BBB" to assign to the $('#formDefault_2')。
,and then I click the hyperlink "BBB", the trace debug can not enter the function '$("#HrefBtn_2").click(function ()'
Default1.aspx=>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default1.aspx.cs" Inherits="Default1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script src="js/jquery-2.1.4.min.js"></script>
<script>
$(function() {
$("#HrefBtn_1").click(function () {
$.ajax({
url: 'Default1.aspx/GetDataTest',
type: 'POST',
data: JSON.stringify(),
contentType: 'application/json; charset=UTF-8',
dataType: "json",
error: function (xhr) {
},
success: function (SuccessReturnVaule) {
var lsHTML;
lsHTML = "<a href='#' id='HrefBtn_2' rel='example'>BBB</a>";
$('#formDefault_2').html(lsHTML);
//$('#formDefault_2').append(lsHTML);
}
});
});
$("#HrefBtn_2").click(function () {
var lsTemp;
lsTemp = "Here!";
});
});
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<div id="formDefault_1">
<a href="#" id="HrefBtn_1" rel="example">AAA</a>
</div>
<div id="formDefault_2">
</div>
</div>
</form>
</body>
</html>
Default1.aspx.cs=>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Web.Services;
using System.Collections;
public partial class Default1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[WebMethod]
public static string GetDataTest()
{
return "";
}
}