JQuery:insertBefore整个对象

时间:2015-08-25 20:11:56

标签: jquery

下面是选择特定对象并在sharepoint 2010中员工目录项列表中的所有对象之前插入的代码。

如果职位名称在managerTitles列表中,如果他们不是第一个,请将此人列为第一个

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
}

代码

$(this).insertBefore($('.psrch-FullResult:first')); 

没有做任何事情,所以代码

$("<div style='display:block;clear:both;'></div>").insertAfter($('.psrch-FullResult:first'));

但是当我尝试写一些东西时

$("<p>testing</p>").insertBefore($('.psrch-FullResult:first'));

它有效

请提出一些解决方案。

0 个答案:

没有答案