如何创建一个页面到另一个页面的锚标记,并打开一个特定的div,我想在codeigniter中显示数据

w1jd8yoj  于 2022-12-07  发布在  其他
关注(0)|答案(1)|浏览(71)

这是第二页

<div class="accordion__item">
    <a href="<?= base_url(); ?>client/progress?id#$habit->id; ?> ">
    <div class="accordion__header collapsed" data-toggle="collapse" data-target="#bordered_no-gutter_collapseThree">
        <span class="accordion__header--text">Progress By Habit</span>
        <span class="accordion__header--indicator style_two"></span>
    </div>
    </a>
    <div id="bordered_no-gutter_collapseThree" class="collapse accordion__body" data-parent="#accordion-four">
    <?php
    if (!empty($all_habits)) {
        foreach ($all_habits as $habit) { ?>
            <div class="accordion__header accordion" id="prog_habit" value="<?= $habit->id; ?>">
                <span class="accordion__header--text"></span><?= $habit->title; ?></span>
            </div>
        <?php }
    } ?>
    </div>
</div>

这是第一页,我想重定向此页:

<a href="<?= base_url() ?>client/progress?id=<?= $habit->id; ?> " class="btn btn-success shadow btn-xs sharp mr-1 mx-1"><i class="fa fa-eye"></i></a>
yhuiod9q

yhuiod9q1#

你需要在第一个页面的网址使用片段像这样:

<a href="<?= base_url() ?>client/progress?id=<?= $habit->id; ?>#mydiv" class="btn btn-success shadow btn-xs sharp mr-1 mx-1"><i class="fa fa-eye"></i></a>

第二页像这样

<div class="accordion__item" id="mydiv">
<a href="<?= base_url(); ?>client/progress?id#$habit->id; ?> ">
<div class="accordion__header collapsed" data-toggle="collapse" data-target="#bordered_no-gutter_collapseThree">
    <span class="accordion__header--text">Progress By Habit</span>
    <span class="accordion__header--indicator style_two"></span>
</div>
</a>
<div id="bordered_no-gutter_collapseThree" class="collapse accordion__body" data-parent="#accordion-four">
<?php
if (!empty($all_habits)) {
    foreach ($all_habits as $habit) { ?>
        <div class="accordion__header accordion" id="prog_habit" value="<?= $habit->id; ?>">
            <span class="accordion__header--text"></span><?= $habit->title; ?></span>
        </div>
    <?php }
} ?>
</div>

我希望这段代码对你有用!编码快乐!

相关问题