<?php
echo '<td class="options-width">'.
'<a href="edituser_lightbox.php?user_id=' . $row['user_id'] . ' " onclick:" $.fancybox({ href:'example.jpg',title : 'Custom Title'});"title="Edit" class="icon-1 info-tooltip" </a>'.
'<a href="deleteuser.php?user_id=' . $row['user_id'] . ' " class="icon-2 info-tooltip"> </a>'.
'<a href="" title="Save" class="icon-5 info-tooltip"> </a>'.
'</td>';
echo "</tr>";
}
?>
我至少要靠近这里吗?你能看到我想做什么吗?我也不能将css更改为包含fancybox :(
最佳答案
onclick
属性应使用=
而不是:
指定,如下所示:
echo '<a href="edituser_lightbox.php?user_id=' . $row['user_id'] . '" onclick="$.fancybox({ href:\'example.jpg\',title : \'Custom Title\'});" title="Edit" class="icon-1 info-tooltip" </a>';
在fancybox语句中,您还需要对单引号进行反斜杠转义,以使它们在输出HTML中显示为文字
'
。在"
属性中的href=
结束之前,您还有一个多余的空间。将JavaScript内联放置在标记内不是一种好的做法。相反,最好像下面这样绑定它:
$("a#editLink").click(function() {
$.fancybox({ href:'example.jpg',title : 'Custom Title'});
});
注意,您需要将
id="editLink"
添加到<a>
标记中。 (它可以是任何id或其他各种jQuery选择器,而不是id
。echo '<a id="editLink" href="edituser_lightbox.php?user_id=' . $row['user_id'] . '" onclick="$.fancybox({ href:\'example.jpg\',title : \'Custom Title\'});" title="Edit" class="icon-1 info-tooltip" </a>';