How can i access html tag that exist inside jquery function check below code , i want to access the [ a link] tag to do another task when user click on it
$.ajax({
type:"POST",
url: "WebForm1.aspx/GetProblems",
data: "{}",
datatype: "json",
contentType: "application/json; charset=utf-8",
success: function (data) {
//Function to cut a string that contain data in format : "problem-id"
for (var i = 0; i < data.d.length; i++) {
var x = data.d[i].search('-');
var problem = data.d[i].slice(0, x);
var id = data.d[i].substr(x+1, 1);
$("#div2").append("<a class='menu' href='webform1.aspx?id="+id+"'>" + problem + "</a> ");
}
},
failure: function (response) {
alert("fail");
}
});
i try to do the following but nothing happened .
$("a").click(function (event) {
event.preventDefault();
alert($(this).attr('href').charAt(13));
}
also try with class name , still the same problem nothing happened .
$(".menu").click(function (event) {
event.preventDefault();
alert($(this).attr('href').charAt(13));
}