下面是我的代码:
jQuery("#test").after("<a id='clearall' href='#' onclick='jQuery(this).remove(); jQuery('.clearselection').remove;'><img src='clearselection.gif'></a>");当我尝试这样做时,我得到一个语法错误:
jQuery(this).remove(); jQuery(<---当我单击链接时,我需要删除链接图像并删除类.clearselection的所有实例。我尝试转义单引号,但这不起作用。任何帮助都将不胜感激。
发布于 2013-04-20 03:06:58
使用jquery来处理,而不是定义内联的click处理程序:
$(document).on("click", "#clearall", function()
{
jQuery(this).remove();
jQuery('#clearselection').remove(); //btw you were missing the parens here
});发布于 2013-04-20 03:07:44
替换为:
onclick='jQuery(this).remove(); jQuery(\'.clearselection\').remove();'https://stackoverflow.com/questions/16111762
复制相似问题