首页 > 解决方案 > 如果输入有值,如何打开折叠?

问题描述

我正在努力做到这一点,如果 div 的任何输入中有值,则显示 div。我正在使用引导崩溃。

我写了一个这样的函数,但它没有用

$(function() {
  $("collapseExample .collapse").each(function () {
if ($(this).find('.kgad2').length > 0)
  $(this).collapse('show');
});
  event.preventDefault();
});

这是html

<div class="collapse" id="collapseExample">
<div class="card card-body">
    <div class="col-md-12">
        <table id="ekkagit" class="table table-condensed">
            <thead>
                <tr>
                    <th bgcolor="#00FF00">
                        <strong>Ek Kağıt 1</strong>
                    </th>
                    <th>Tabaka</th>
                    <th>Kg Fiyatı</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>
                        <input id="kgad2" name="kgad2" type="text" value="">
                            <?php echo $sonuc['kgad2'] ?>" class="form-control inst_amount7">
                        </td>
                        <td>
                            <input id="kgfiyat2" name="kgfiyat2" type="text" value="">
                                <?php echo $sonuc['kgfiyat2'] ?>" class="form-control inst_amount7">
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>

标签: jquerybootstrap-4

解决方案


推荐阅读