我的href链接中的确认消息无效。
这是我的代码:
<?php
echo '<a href="'.$delete_url.'" title="delete" onclick="return confirm("Are you sure you want to Remove?");">
<img src="'.base_url().'images/dashboard-delete-icon.png" alt="delete icon" role="presentation" width="14" height="16"/>
</a>'?>
请帮助,我正在做什么错误。
答案 0 :(得分:2)
onclick
处理程序在"Are
之前的双引号后结束。
<?php echo '<a href="'.$delete_url.'" title="delete" onclick="return confirm("Are you sure you want to Remove?");">
您应该使用单引号并将其转义,以便您可以从php正确回显它:
... onclick="return confirm(\'Are you sure you want to Remove?\');"> ...
答案 1 :(得分:1)
检查你的报价:
<?php echo '<a href="'.$delete_url.'" title="delete" onclick="return confirm("Are you sure you want to Remove?");">
将onclick
替换为:
onclick="return confirm(\'Are you sure you want to Remove?\');">