Selector cannot find ajax element?
- function GetDepartmentTree() {
$.ajax({
type: "POST",
url: "Service/service.asmx/GetDepartmentTree",
dataType: "json",
contentType: "application/json; charset=utf-8",
data: "",
success: function(data) {
$(".DivTreeView").html(data.d);
},
error: function(x, e) {
alert(x.responseText);
},
complete: function(x) {
alert(x.responseText);
}
});
}
- $("#NavigationDepartmentList span").click(function() {
alert($(this).text());
});
It is not work.
- $(".DivTreeView").html("<ul id='NavigationDepartmentList'><li><span>span1</span><ul> <li><span>span2</span><ul></ul>");
- $("#NavigationDepartmentList span").click(function() {
alert($(this).text());
});
It work fun.