Content is not added in one of the appended textareas
<p>I have a function below where the if statement works when it comes to adding content into a single textarea when clicking the "Add" button:</p>

<pre><code>function addwindow(questionText) { 

    if(window.console) console.log();

    if($(plusbutton_clicked).attr('id')=='mainPlusbutton') { 
        $('#mainTextarea').val(questionText); 
        } else { 
            $(plusbutton_clicked).parent('td').next('td.question').find('textarea.textAreaQuestion').val(questionText);
            }

    $.modal.close(); 
    return false;
}
</code></pre>

<p>Below is the code for the single textarea and it's plus button:</p>

<pre><code>&lt;form id="QandA" action="&lt;?php echo htmlentities($action); ?&gt;" method="post"&gt;

&lt;div id="detailsBlock"&gt;
&lt;table id="question"&gt;
&lt;tr&gt;
    &lt;td rowspan="3"&gt;Question:&lt;/td&gt; 
    &lt;td rowspan="3"&gt;
        &lt;textarea class="questionTextArea" id="mainTextarea" rows="5" cols="40" name="questionText"&gt;&lt;/textarea&gt;
    &lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;

&lt;table id="plus" align="center"&gt;
&lt;tr&gt;
&lt;th&gt;
&lt;a onclick="return plusbutton();"&gt;
&lt;img src="Images/plussign.jpg" width="30" height="30" alt="Look Up Previous Question" class="plusimage" id="mainPlusbutton" name="plusbuttonrow"/&gt;
&lt;/a&gt;
&lt;span id="plussignmsg"&gt;(Click Plus Sign to look &lt;br/&gt; up Previous Questions)&lt;/span&gt;
&lt;/th&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;/form&gt;
</code></pre>

<p>The problem is the else statement is not working when it comes to adding content within one of the appended textareas below. What I want is that if a user clicks on a Plus button next to one of the appended textarea and adds a content by clicking on the "Add" button, the textarea which belongs in the same row as the plus button which was clicked on will add the content. What do I need to change in order to do this?</p>

<p>Below is the code whch shows the textareas and plus buttons which are appended:</p>

<pre><code>    var plusbutton_clicked;

 function insertQuestion(form) {


var $tbody = $('#qandatbl &gt; tbody'); 
var $tr = $("&lt;tr class='optionAndAnswer' align='center'&gt;&lt;/tr&gt;");
var $plusrow = $("&lt;td class='plusrow'&gt;&lt;/td&gt;");
var $question = $("&lt;td class='question'&gt;&lt;/td&gt;");


 $('.questionTextArea').each( function() {

 var $this = $(this);
var $questionText = $("&lt;textarea class='textAreaQuestion'&gt;&lt;/textarea&gt;").attr('name',$this.attr('name')+"[]")
.attr('value',$this.val());

 $question.append($questionText);

});

 $('.plusimage').each( function() {

var $this = $(this);
var $plusimagerow = $("&lt;a onclick='return plusbutton();'&gt;&lt;img src='Images/plussign.jpg' width='30' height='30' alt='Look Up Previous Question' class='imageplus'/&gt;&lt;/a&gt;").attr('name',$this.attr('name')+"[]")
.attr('value',$this.val());

$plusrow.append($plusimagerow);

 });

$tr.append($plusrow);
$tr.append($question);
$tbody.append($tr);                     

}
</code></pre>

<p>You can view application <a href="http://helios.hud.ac.uk/u0867587/Mobile_app/QandATable2.php" rel="nofollow">here</a>. Please follow the steps to use the application:</p>

<ol>
<li>Click on "Add Question" button, then will add a textarea within a new row.</li>
<li>Click on the "Green Plus" button within the table row you just added, a modal window will appear.</li>
<li>In modal window it displays a search bar, in search bar type in "AAA" and click on "Search" button</li>
<li>Results will appear of your search, click on "Add" button to add a row. You will find out modal window is closed but the content from the "Question" field is not added in the textarea within the row you clicked on the green plus button</li>
</ol>

<p>If you did the steps in the top textarea (the one above the horizontal line), then it does work, it just doesn't work for textarea which you have just added </p>
