在PHP的表格中添加onclick事件

时间:2018-11-29 14:31:48

标签: javascript php

我尝试将此行添加到我的PHP代码中:

<a href="#" onClick="window.open('yourpage.htm','pagename','resizable,height=640,width=360'); return false;">New Page</a>

PHP:

$html_table .= "<td> <a href="#" onClick="window.open('mypage.htm','pagename','resizable,height=640,width=360'); return false;"><button type='button' class='btn btn-success'>test</button></a></td>";

但是它不能与"一起使用。

更改我的代码的最佳方法是什么?

谢谢

1 个答案:

答案 0 :(得分:1)

您需要转义引号:

<?php

$html_table .= "<td> <a href=\"#\" onClick=\"window.open('mypage.htm','pagename','resizable,height=640,width=360'); return false;\"><button type='button' class='btn btn-success'>test</button></a></td>";
相关问题