gpt4 book ai didi

jquery - 更改父div之后的div的css

转载 作者:行者123 更新时间:2023-12-01 03:09:36 25 4
gpt4 key购买 nike

您好,我想将类添加到父 div 之后的 div 的范围中。

HTML

<div class="stepwizard">
<ul class="stepwizard-row">
<li class="stepwizard-step">
<span class="step-border"><a href="#step1" class="data-toggle="tab">1</a></span>
//If user click here <span class="step1"> should be change
</li>
<li class="stepwizard-step">
<span class=""><a href="#step2" data-toggle="tab" >2</a></span>
//If user click here <span class="step2"> should be change
</li>
<li class="stepwizard-step">
<span class=""><a href="#step3" class="p-n-t step-tab" aria-controls="documents" role="tab" data-toggle="tab">3</a></span>
//If user click here <span class="step3"> should be change
</li>
</ul>
</div>
<div class="m-t-sm step-title">
<span class="step1">BASIC INFO</span> //here i want to add class
<span class="step2">REGISTERED NUMBERS</span>
<span class="step3">CLIENT SERVICES</span>
</div>

此处当用户单击<a>时我想将类添加到 <span> 标签在 <div class="m-t-sm step-title"> 之后.

如何使用 jquery 做到这一点?

最佳答案

请尝试一下

$(document).ready(function(){
$("a").click(function(){
var position = $(this).attr('href').split("#")[1];
$('.'+position ).addClass('your_class')
});
});

关于jquery - 更改父div之后的div的css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34873861/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com