Read more button not working with text()->kt()

Hello, hope you’re all good.
I have two small questions, I try to have a link with read more text. To get there I’m using a simple css exemple I found online.

  • is it a good practice? what would be best?
  • with a simple text field the hide/show it is working, even with <?= $item->text()?>, but if I ask for ->markdown() or ->kt() then it show the text but the read more is not working anymore

Can you help me? Thank you

$items = false;
if($root = $pages->findOpen()) {
  $items = $root->children()->listed();
if($items and $items->isNotEmpty()):
<?php foreach($items as $item): ?>
<li class="separateur">
  <?php e($item->isOpen(), 'class="active"') ?>
    <h1><?= $item->title()->kt() ?></h1>
    <?= h($item->subtitle()->markdown(), true) ?>
      <input class="read-more-state" id="read-more-controller" type="checkbox">
      <div class="read-more-wrap">
      <p class="read-more-target"><?= $item->text()->markdown() ?></p>
      <label class="read-more-trigger" for="read-more-controller"></label>
<?php endforeach ?> <?php endif ?>

Don’t know if it’s part of the issue, but you shouldn’t use markdown or kt inside p tags. Use kti() instead or remove the p tag in favor of a div/article or whatever tag.

Thank you, I try to change the p in a div, and then change the css for the div, but still doesn’t work
<div class="read-more-target"><?=$item->text()->markdown() ?></div>
I am still not very good in code, is that the way to do it?

Ok I found another code that seems to work better, thanks