我需要在javascript函數中創建一個帶有ajax的行,但是我在查找正確的語法時遇到了很多麻煩。javascript ajax語法創建html行
這是HTML最終的結果,我想:
<td style="text-align:center">
<input type="image" src="nienteico.png" style="cursor:pointer; width:40px; height:40px" id="5.51" class="ajaxEdit" onclick="cambiastato(5.51)">
</td>
,這是修改需要的JS代碼:
<td style="+'text-align:center'+"><input type="+'image'+" src="+'nienteico.png'+" style="+'cursor:pointer; width:40px; height:40px'+" id="+'5.51'+" class="+'ajaxEdit'+" onclick="+'cambiastato(5.51)'+"></input></td>
最後,這是我獲得使用JS的HTML我已經寫過:
<td style="text-align:center"><input type="image" src="nienteico.png" style="cursor:pointer;" width:40px;="" height:40px="" id="5.51" class="ajaxEdit" onclick="cambiastato(5.51)"></td>
在此先感謝!
不要試圖用搗碎串在一起寫HTML JS。使用DOM。 'createElement','setAttribute','appendChild'等。管理起來更容易。 – Quentin 2014-12-07 12:48:35
最新的問題是什麼?缺失的新行? – elcuco 2014-12-07 12:48:36
對不起,但我想你應該先問一下[this](http://eloquentjavascript.net/),然後再問問關於JavaScript的問題,然後討論關於AJAX本身[入門AJAX](https://developer.mozilla.org/en-US/docs/AJAX/Getting_Started) – Givi 2014-12-07 12:49:29