jQuery innerHTML does not work properly (!)

Posted by Kayes on Stack Overflow See other posts from Stack Overflow or by Kayes
Published on 2010-06-08T15:22:38Z Indexed on 2010/06/08 15:32 UTC
Read the original article Hit count: 210

Filed under:
|

I was trying to build an <a> tag and set it in a <td> of a table. The string is built perfectly but when I set this as the innerHTML using jQuery, the string gets broken. I can't figure out why this is happening? Any clues?

Here's the string I want to set in the <td>:

<a onclick='return EditIssueItemBatch('1c1e27a2-beac-4772-a26f-6a7e05529a65', '498ba483-ca06-4b23-b3a9-0085e4760ff1')'>Edit</a>

But here is how it looks after setting as innerHTML:

<A onclick="return EditIssueItemBatch(" ?498ba483-ca06-4b23-b3a9-0085e4760ff1?)? 1c1e27a2-beac-4772-a26f-6a7e05529a65?,>Edit</A>

And the following is my code-snippet..

var tr = $("#itemIssueBatchListTable > tbody:last").children()[data.Index + 1];
...
...
var strBuff = [];
strBuff.push("<a onclick='return EditIssueItemBatch('");
strBuff.push(data.ItemIssueBatch.ItemCode_FK);
strBuff.push("', '");
strBuff.push(data.ItemIssueBatch.StockDetCode_FK);
strBuff.push("')'>Edit</a>");
tr.cells[9].innerHTML = strBuff.join("");
...
...

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery