gpt4 book ai didi

jquery - 当我们点击 href 类 ="credit"时,任何人都可以告诉我如何定位 div id ="toggle"

转载 作者:行者123 更新时间:2023-11-28 16:31:52 24 4
gpt4 key购买 nike

<div class="row">
<div class="col-md-12">
<p><a href="#credits" class="toggle btn btn-primary"><?php print $title; ?></a></p>

<div id="credits1" class="wysiwyg hidden">
Content - content
</div>

</div>

    <div class="row">
<div class="col-md-12">
<p><a href="#credits" class="toggle btn btn-primary"><?php print $title; ?></a></p>

<div id="credits2" class="wysiwyg hidden">
Content - content
</div>

</div>

<div class="row">
<div class="col-md-12">
<p><a href="#creditsn" class="toggle btn btn-primary"><?php print $title; ?></a></p>

<div id="credits" class="wysiwyg hidden">
Content - content
</div>

</div>

谢谢

最佳答案

你可以使用被点击元素的href属性作为选择器:

$('.toggle').click(function(e) {
e.preventDefault();
var $target = $($(this).attr('href'));
// do something with the $target div here...
});

Working fiddle

关于jquery - 当我们点击 href 类 ="credit"时,任何人都可以告诉我如何定位 div id ="toggle",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35604376/

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