<?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 :(
发布于 2012-08-06 00:12:00
看起来像是打字错误:
onclick:"将冒号设为等号:
onclick="另外,通过添加引号来确保对象的属性值为字符串。
onclick='$.fancybox({href: "'example.jpg'", title: "'Custom Title'"});'发布于 2012-08-06 00:12:45
应使用=而不是:指定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>';https://stackoverflow.com/questions/11817927
复制相似问题