扩展/折叠按钮Won'

Epand/Collapse Toggle Won't Float Down with Expanding Content

本文关键字:Won 按钮 折叠 扩展      更新时间:2023-09-26

我有一些展开/折叠代码的问题。我希望HTML中的p class="heading"标签(这是切换展开/折叠框的标签)随着展开的内容向下移动。现在,内容正在扩展并填充在按钮下方。

我试着弄乱代码,但是扩展函数不能工作,所以我很抱歉不能提供一个。

问题代码如下。

CSS

<style>
        /* mouse over link */
        p {
        color: rgb(206, 134, 57);
        margin-left: -10px;
        margin-right: -10px;
        margin-bottom: 0px;
        transition: background .75s ease-in-out, box-shadow .5s ease-in-out;
        }
        p:hover { text-decoration: underline;
        cursor: pointer;
        color: rgb(206, 134, 57);
        -moz-box-shadow: 0 -2px 2px;
        -webkit-box-shadow:  0 -2px 2px;
        box-shadow: .1px .1px 5px .1px #787878;
        }
        .heading {
        font-family:Arial, Helvetica, sans-serif;
        font-size:13px;
        text-align: center;
        padding:7px 14px 7px 12px;
        border-bottom-left-radius:5px;
        border-bottom-right-radius:5px;
        text-decoration:none;
        background: -moz-linear-gradient(top, #dedede, white 75%);
        background: -webkit-gradient(linear, 0 0, 0 75%, from(#dedede), to(white));
        border-top: 1px solid #A6A6A6;
        outline:none;
        }
        a {
        color: rgb(206, 134, 57);
        }
        .heading:hover {
        transition: background .75s ease-in-out, box-shadow .5s ease-in-out;
        }
        a:hover {
        color: rgb(137, 90, 39);
        }
        .transition {
        border: 1px solid #A6A6A6;
        border-radius: 5px;
        background:white;
        padding-top: 7px;
        padding-right: 10px;
        padding-bottom: 0px;
        padding-left: 10px;
        transition: background .75s ease-in-out, box-shadow .5s ease-in-out;
        }
        .transition:hover {
        background:#e6ebef;
        box-shadow: .1px .1px 5px .1px #787878;
        transition: background .75s ease-in-out, box-shadow .5s ease-in-out;
        }
    </style>
JQuery JavaScript/

    <script type="text/javascript">
jQuery(document).ready(function() {
jQuery(".content").hide();
//toggle the componenet with class msg_body
jQuery(".heading").click(function() {
 var s = $(this);
jQuery(this).next(".content").slideToggle(500);
 s.html(s.text() == 'Click here for less information...' ? 'Click here for more information...' : 'Click here for less information...');
});
});
</script>
HTML

<div class="transition"><span style="font-weight: bold; font-size: 18px; color: rgb(0, 130, 200);"><u>Tree Removal Permit</u><br>
    </span>&nbsp;<br>
    A tree removal permit is required for removal of any tree on a commercial or multi-family property.<br>
    <p class="heading">Click here for more information...&nbsp;</p>
    <div class="content">
    <div style="height:7px;font-size:7px;">&nbsp;</div>
    <span style="font-size: 14px; color: rgb(6, 78, 137);"><b>Online Application Process</b></span>
    <ul>
        <li type="square">For an easy, step-by-step permit application process visit our Online Licensing and Permitting Portal</a>.</li>
    </ul>
    <div style="height:7px;font-size:7px;">&nbsp;</div>
    </div>
    </div>

任何帮助都将非常感激!

您的<div class="content"..在less information按钮上方。把它放在<p class="heading"..前面,改变这一行

jQuery(this).next(".content").slideToggle(500);

jQuery(this).prev(".content").slideToggle(500);

你是这个意思吗?https://jsfiddle.net/inkedraskal/319j8vwr/

你需要将"p"标签移动到"content"div下面,然后相应地切换js:

jQuery(document).ready(function() {
    jQuery(".content").hide();
    //toggle the componenet with class msg_body
    jQuery(".heading").click(function() {
        var s = $(this);
        jQuery(".content").slideToggle(500);
        s.html(s.text() == 'Click here for less information...' ? 'Click here for more information...' : 'Click here for less information...');
    });
});