I cannot read the dynamically added from my edit method. The rows are dynamically added and the rows contains span with Id. I am trying to read the content of the span from another jquery method. Both the methods are given below.
function AddQuestionChoice() {
var table = $("#questionOptionsTable");
var index = $('#questionOptionsTable tr').length - 1;
var choiceSequenceNo = $("#choiceSequenceNo").val();
var choiceText = $("#choiceText").val();
if (!$("#choiceSequenceNo").val())
{
alert("Enter sequence number");
return;
}
if (!$("#choiceText").val())
{
alert("Enter choice");
return;
}
if (!$.isNumeric(choiceSequenceNo))
{
alert("Enter valid sequence number.")
return;
}
var row = "<tr bgcolor='#fff'><td id='choiceDiv[" + index + "]'> <span name= 'eventSurveyQuestion.Sequences[" + index + "]' id='eventSurveyQuestion.Sequences[" + index + "]'>" + choiceSequenceNo + "</span> </td><td> <span name='eventSurveyQuestion.Options[" + index + "]' id='eventSurveyQuestion.Options[" + index + "]'>" + choiceText + "</span> </td>" +
"<td><a href='javascript:EditQuestionChoice(" + index + ");'><img src='/Content/themes/Default/images/action1.png'></a> <a href='javascript:RemoveQuestionChoice(" + index + ");'><img src='/Content/themes/Default/images/action2.png'></a></td></tr>";
$('#questionOptionsTable').append(row);
var length = $('#questionOptionsTable tr').length;
$("#choiceSequenceNo").val(length);
$("#choiceText").val('');
}
function EditQuestionChoice(index)
{
var sequenceNumber = $("#eventSurveyQuestion.Sequences["+index + "]").text();
alert(sequenceNumber);
var choiceText = $("#eventSurveyQuestion.Options["+ index +"]").text();
$("#choiceSequenceNo").val(sequenceNumber);
$("#choiceText").val(choiceText);
}