我有以下功能:
function go_to(sec,name) {
$("#lib_nav td:nth-child(2)").append('<span> > <a style="cursor:pointer" OnClick="$(\'.content\')
.html(\'<p>Loading</p>\')
.load(\'_library_q.php?\',\'sec='+sec+'\')>'+name+'</a></span>');
$('.content').html('<p>Loading</p>')
.load('_library_q.php?','sec='+sec);
}
由
之类的脚本调用<div class="darkbox" style="cursor:pointer" OnClick="go_to(2,'Hello World');">
问题是,在.append行中,它只追加<span> > </span>
并完全跳过<a>
。但是,第二个.load
函数有效。有什么想法吗?
答案 0 :(得分:0)
我认为你错过了onclick处理程序的结束双引号:
function go_to(sec,name) {
$("#lib_nav td:nth-child(2)").append('<span> > <a style="cursor:pointer" OnClick="$(\'.content\')
.html(\'<p>Loading</p>\')
.load(\'_library_q.php?\',\'sec='+sec+'\')">'+name+'</a> </span>');
$('.content').html('<p>Loading</p>')
.load('_library_q.php?','sec='+sec);
}