Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JQuery:在整个对象之前插入_Jquery - Fatal编程技术网

JQuery:在整个对象之前插入

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

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

如果该职位在
管理人员列表中,如果该人员不是第一位,则将其列为列表中的第一位

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'));