asp.net - 选择 Accordion 选项卡时切换子元素的类

标签 asp.net html css ajax

我正在努力想出一种方法来切换位于我的 Ajax Accordion header 中的标签的 css 类。

我希望 header 内的 span 标记的类根据是否选择了特定 header 而改变(基本上将加号图标更改为减号图标)。 Accordion 部分的代码如下。我还没有尝试创建 JS 或 Jquery 脚本。

<asp:Accordion 
    ID="Accordion1"   
    CssClass="accordion"  
    HeaderCssClass="acc_Header"  
    HeaderSelectedCssClass="acc_HeaderSelected"  
    ContentCssClass="accordionContent" 
    AutoSize ="none"
    RequireOpenedPane="false"
    FadeTransitions ="true"
    TransitionDureation="250"
    FramesPerSecond="40"
    SelectedIndex="-1"
    SuppressHeaderPostBack ="true"
    runat="server">
        <Panes>
            <asp:AccordionPane ID="SubsidencePane1" runat="server">
                <Header><span class="icon-plus-circle"></span>What is the definition of subsidence?</Header>
                <Content>
                    <p>This is where the ground beneath a structure has suffered downward movement, causing damage to the property.</p>  
                    <p>The movement of the ground is a consequence of some activity in the ground unconnected with the weight or presence of the building.</p>
                    <p>The damage that normally occurs in properties suffering from subsidence is cracking in the walls; these cracks can be diagonally, vertical or horizontal.</p>  
                    <p>However not all cracking is attributable to subsidence therefore a specialist surveyor is often called upon to determine the cause of the cracking to ensure the cause falls under the definition of subsidence.</p>
                </Content>
            </asp:AccordionPane>

最佳答案

使用以下代码解决了问题:

$(document).ready(function () {
        $(".accordion div").click(function () {
            $("> span", this).toggleClass("icon-plus-circle icon-minus-circle");
        });

关于asp.net - 选择 Accordion 选项卡时切换子元素的类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16320274/

相关文章:

c# - AsyncFileUpload 回发导致双重上传

html - 即使使用 Bootstrap 并且不使用 px,网页也没有响应

c# - 将表中的数据绑定(bind)到前端的转发器

css - 如何删除 Wordpress 页脚下的空白区域?

javascript - 计算动态创建的 Div 元素和所有子元素的加载时间

Jquery 更改显示 css 无法正常工作

c# - UpdateProgress 不会在 UpdatePanel 内的每个 PostBack 控件上触发

c# - 更新后需要使行处于正常模式

asp.net - AWS SNSClient发布请求的超时错误

JavaScript 脚本未加载