在 php print 函数中编写具有参数的 onclick 方法
Write onclick method that has parameters in php print function
我在 php 打印中编写 onclick 方法时遇到问题,代码如下:
<?php print "<p><small> <a href='#' onclick='ajaxMenu('comments.php?news=".$fileContent['id']."');>".$number. " ".$text." </small> </a> </p>"; ?>
给定的代码无效。我相信这是因为其中包含单引号和双引号。谁能帮我解决这个问题?
您可以使用正斜杠转义 " 字符 \"
<?php echo( "<a href=\"#\" onclick=\"onMenu('this is the menu');\">This is a link</a>" ); ?>
我在 php 打印中编写 onclick 方法时遇到问题,代码如下:
<?php print "<p><small> <a href='#' onclick='ajaxMenu('comments.php?news=".$fileContent['id']."');>".$number. " ".$text." </small> </a> </p>"; ?>
给定的代码无效。我相信这是因为其中包含单引号和双引号。谁能帮我解决这个问题?
您可以使用正斜杠转义 " 字符 \"
<?php echo( "<a href=\"#\" onclick=\"onMenu('this is the menu');\">This is a link</a>" ); ?>