How to retrieve id's
<p>I hav a php code where it displays buttons from A-Z:</p>

<pre><code>  &lt;table id="optionAndAnswer" class="optionAndAnswer"&gt;
    &lt;tr class="answer"&gt;
    &lt;td&gt;3. Answer&lt;/td&gt;
    &lt;td&gt;
        &lt;?php
            $a = range("A","Z");
        ?&gt;

        &lt;table id="answerSection"&gt;
            &lt;tr&gt;

        &lt;?php
            $i = 1;
            foreach($a as $key =&gt; $val){
                if($i%7 == 1) echo"&lt;tr&gt;&lt;td&gt;";
                echo"&lt;input type=\"button\" onclick=\"btnclick(this);\" value=\"$val\" id=\"answer".$val."\" name=\"answer".$val."Name\" class=\"answerBtns answers answerBtnsOff\"&gt;";      
                if($i%7 == 0) echo"&lt;/td&gt;&lt;/tr&gt;";
                $i++;
            }
        ?&gt;

...
</code></pre>

<p>What I am trying to do is create a template for the above code in jquery so that if the user wants to add these buttons into a block, then jquery can be used to add these buttons in a block, exactly like a template.</p>

<p>Below is jquery code:</p>

<pre><code>var $this, i=0, $row, $cell;
$('#optionAndAnswer .answers').each(function() {
    $this = $(this);
    if(i%7 == 0) {
        $row = $("&lt;tr/&gt;").appendTo($answer);
        $cell = $("&lt;td/&gt;").appendTo($row);
    }
    var $newBtn = $("&lt;input class='answerBtnsRow answers' type='button' style='display:%s;' onclick='btnclick(this);' /&gt;".replace('%s',$this.is(':visible')?'inline-block':'none')).attr('name', $this.attr('name')).attr('value', $this.val()).attr('class', $this.attr('class'));


    $newBtn.appendTo($cell);

    i++;
});
</code></pre>

<p>Now this works fine but I have one issue. If you look at the php code, each button has its own id, in my jquery code, each buttons does not have its own id. In my jquery code I want each button to have the same id as their counterparts in php code except only difference is that I want the jquery button id's to end with "Row". E.g. if id for button F in php is <code>#answerF</code>, then I want button F in jquery to have id <code>#answerFRow</code>.</p>

<p>My question is that is this possible? Will this code be able to retrieve the buttons id from php code if I put it in jquery code:</p>

<pre><code>.attr('id', $this.attr('id'))
</code></pre>

<p>And how do I insert the word "Row" at the end?</p>
