JQuery:在整个对象之前插入
下面是选择特定对象并在sharepoint 2010中员工目录项列表中的所有对象之前插入的代码 如果该职位在JQuery:在整个对象之前插入,jquery,Jquery,下面是选择特定对象并在sharepoint 2010中员工目录项列表中的所有对象之前插入的代码 如果该职位在管理人员列表中,如果该人员不是第一位,则将其列为列表中的第一位 if($.inArray(jobTitle3, managerTitles) >= 0) { // If they're not first in the list, move them there" if(personIndex > 0) { // Move the manager
管理人员列表中,如果该人员不是第一位,则将其列为列表中的第一位
if($.inArray(jobTitle3, managerTitles) >= 0) {
// If they're not first in the list, move them there"
if(personIndex > 0) {
// Move the manager to first
$(this).insertBefore($('.psrch-FullResult:first'));
}
// Insert a block div to create a line break after the manager
$("<div style='display:block;clear:both;'></div>").insertAfter($('.psrch-FullResult:first'));
//removed this line due to need for multiple heads of a dept -- return false;//Leave the .each iterator
}
不做任何事情,所以代码
$("<div style='display:block;clear:both;'></div>").insertAfter($('.psrch-FullResult:first'));
$(“”).insertAfter($('.psrch-FullResult:first');
但是当我试着写一些
$("<p>testing</p>").insertBefore($('.psrch-FullResult:first'));
$(“测试”).insertBefore($('.psrch FullResult:first');
它起作用了
请提供一些解决方案。请提供更多的背景信息。什么是此
?需要在之前显示更多上下文,如果要查看此
是什么。此
很可能不是HTML元素,这就是它不做任何事情的原因。您确定没有添加div
?它只是一个空白的div
什么都不会显示,但它仍然可以在那里显示html结构…可能可以使用prepend()
,它将插入到容器的开头这表示当前对象
$("<p>testing</p>").insertBefore($('.psrch-FullResult:first'));