Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/52.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将类添加到特定div之后的第一个部分_Jquery - Fatal编程技术网

使用jQuery将类添加到特定div之后的第一个部分

使用jQuery将类添加到特定div之后的第一个部分,jquery,Jquery,HTML: 一些花哨的代码。 一些别致的款式。 如何将带有jquery的类添加到标题后的第一部分? $('header~ section:first')。addClass('test') .test{ 颜色:绿色; } 一些花哨的代码。 一些别致的款式。 部分 部分 部分 $('header~ section:first')。addClass('test') .test{ 颜色:绿色; } 一些花哨的代码。 一些别致的款式。 部分 部分 部分 $('header~ section:f

HTML:


一些花哨的代码。
一些别致的款式。
如何将带有jquery的类添加到标题后的第一部分?

$('header~ section:first')。addClass('test')
.test{
颜色:绿色;
}

一些花哨的代码。
一些别致的款式。
部分
部分
部分
$('header~ section:first')。addClass('test')
.test{
颜色:绿色;
}

一些花哨的代码。
一些别致的款式。
部分
部分
部分
$('header~ section:first')。addClass('test')
.test{
颜色:绿色;
}

一些花哨的代码。
一些别致的款式。
部分
部分
部分
$('header~ section:first')。addClass('test')
.test{
颜色:绿色;
}

一些花哨的代码。
一些别致的款式。
部分
部分
部分
使用以下方法:

<header id="header" class="">
    <div class="header-top-row">

Some fancy code.        

    </div>
</header>

<style>
Some fancy styles.
</style>

<section>
</section>

<section>
</section>

<section>
</section>
使用以下命令:

<header id="header" class="">
    <div class="header-top-row">

Some fancy code.        

    </div>
</header>

<style>
Some fancy styles.
</style>

<section>
</section>

<section>
</section>

<section>
</section>
使用以下命令:

<header id="header" class="">
    <div class="header-top-row">

Some fancy code.        

    </div>
</header>

<style>
Some fancy styles.
</style>

<section>
</section>

<section>
</section>

<section>
</section>
使用以下命令:

<header id="header" class="">
    <div class="header-top-row">

Some fancy code.        

    </div>
</header>

<style>
Some fancy styles.
</style>

<section>
</section>

<section>
</section>

<section>
</section>
请尝试下面的代码


预编演示
$('document').ready(函数(){
$(“正文部分”).first().addClass('test');
})
尝试下面的代码


预编演示
$('document').ready(函数(){
$(“正文部分”).first().addClass('test');
})
尝试下面的代码


预编演示
$('document').ready(函数(){
$(“正文部分”).first().addClass('test');
})
尝试下面的代码


预编演示
$('document').ready(函数(){
$(“正文部分”).first().addClass('test');
})
$('header')。兄弟姐妹('section:first')
..。
$('header')。兄弟姐妹('section:first')
..。
$('header')。兄弟姐妹('section:first')
。。。。。??