[英]Javascript “onclick” doesn't work embed with html & php
我的刪除鏈接帶有一個會提示“是”或“否”的javascript。但是我什么也沒提示。 我可以猜到這是從php等逃脫出來的。誰把我的代碼停下來了? “ onclick”使用“'”。 並且消息使用“'”。 那是問題嗎? 我該如何解決呢?
PHP / JS
echo "<td><a href='time.php?id=".$row['id']."' onclick='return confirm('Are you sure to delete this ?');'><span class='glyphicon glyphicon-remove text-danger'></span></a></td>";
您沒有逃避“您確定...”周圍的引號。 使用\\
轉義它們:
echo "<td><a href='time.php?id=".$row['id']."' onclick='return confirm(\"Are you sure to delete this ?\");'><span class='glyphicon glyphicon-remove text-danger'></span></a></td>";
這將輸出以下HTML:
<td><a href='time.php?id=XX' onclick='return confirm("Are you sure to delete this ?");'><span class='glyphicon glyphicon-remove text-danger'></span></a></td>
您有報價問題。 正確通過將解決問題。
這樣做:
echo "<td><a href='time.php?id=".$row['id']."' onclick='return confirm(\"Are you sure to delete this ?\");'><span class='glyphicon glyphicon-remove text-danger'></span></a></td>";
讓我知道進一步的查詢。
嘗試此操作您忘記在代碼中使用\\
echo "<td><a href='time.php?id=".$row['id']."' onclick='return confirm(\"Are you sure to delete this ?\");'><span class='glyphicon glyphicon-remove text-danger'></span></a></td>";
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.