我有一个问题,我试图通过javascript动态地添加一些html,并且html有一个js函数,它应该在单击时触发,但是我不管我做了什么,总是得到这个错误Uncaught SyntaxError: Unexpected token }
有没有人有过这个问题?这一直困扰我。onClick函数是导致“未捕获的SyntaxError:意外的令牌}”错误
我的代码是:
<?php
foreach($folder_info as $show)
{
echo '<table><tr>';
echo '<span class="glyphicon glyphicon-folder-close" onclick="'.site_url().'/gallery/upload_images" aria-hidden="true" style="font-size:100px;"></span><br/>'.$show['folder_name'];
echo '</tr></table>';
}
?>
当我收到错误?任何人都可以帮我段与PHP和HTML正确行..
你预计会发生什么事'onclick =“”'? –
Andreas
如果你得到一个JS错误,那么请在查看生成它的PHP之前查看JS **。 – Quentin
不能帮助你解决这个问题,因为我们不知道你的site_url()返回了什么。虽然我猜你需要阅读一些关于如何编写'onclick'属性的内容。 – Dellirium