我得到了這個錯誤。我無法找到它有什麼問題。我使用PHP和JavaScript。更改所有使用javascript的元素類名稱的樣式
下面我有我的代碼隱藏的iframe:
<iframe id="hidden_form_submitter" name="hidden_form_submitter" style="width:100%;height:1px;visibility:hidden"></iframe>
我有這行代碼,動作按鈕,其中一個排的id
將發送作爲URL參數:
<tr bgcolor="#d1ffcf" class="row-<?=$transaction['id']?>">
<td>
<a class="done-btn" data-confirm="Are you sure?" href="?action=change&status=done&transact_id=<?=$transaction['id']?>" target='hidden_form_submitter' title="Click if matched!"> Done</a>
</td>
</tr>
Then lastly I have this code on top to update the row in my database:
<?
if($_GET['action'] == 'change'){
//update query here
echo "<script>window.parent.document.getElementsByClassName('row-{$get['id']}').style.backgroundColor='green';</script>";
exit;
}
?>
在我的服務器更新端沒有問題。 問題是我想改變所有相同類的bgcolor而不重新加載整個頁面的JavaScript。
更新:無法更改每個類的背景。例如,我有這個參數要發送。 ?action=change&status=done&transact_id=1608
所以所有具有類row-1608
的元素都應該改變背景顏色或改變某種風格。
只是嘗試刪除{}在JavaScript –
試圖刪除它是在我的編輯器synthax錯誤。 –
將其更改爲「'row - 」。$ get ['id']。「''給了我同樣的錯誤。 –