简体   繁体   English

在移动页面上展开/折叠

[英]Expand/Collapse on mobile page

I have a weird thing happening. 我发生了一件奇怪的事。

I have a page that with several items on it, and each one has an iconfont. 我有一个页面,上面有几个项目,每个项目都有一个iconfont。 When the icon is clicked it changes the icon, and a new 单击该图标时,它将更改该图标,并新建一个

element shows below it. 元素显示在其下方。 And of course, the opposite happens, clicking again changes back the icon and hides it. 当然,情况恰恰相反,再次单击可更改图标并将其隐藏。 This works great. 这很好。

However, when I try to make it work on a mobile version, which is called "modal" (and it kind of is a modal), the expand/collapse does not work. 但是,当我尝试使其在称为“模式”的移动版本上工作时(某种程度上是模式的),展开/折叠无效。 The main modal appears when clicked by a button, so that is not a problem. 当通过按钮单击时,将出现主要模态,所以这不是问题。 I am using the Chrome emulator for an iPhone 5. The same function is called, and I have verified it finds the function, but it won't expand (so I can't test collapsing either). 我正在使用iPhone 5的Chrome模拟器。调用了相同的函数,并且我已经验证它可以找到该函数,但是它不会扩展(因此我也无法测试折叠)。

This is the basic HTML: 这是基本的HTML:

        <p><span id="CraveTV" class="featureToggle plus-fa"></span> CraveTV </p>
        <p id="CraveTV_list" class="goApps">Stream Showtime hits, HBO classics, the best sitcoms in TV history, and CraveTV originals.  Available on <a href="">iOS</a> or <a href="">Android</a>.</p>

The css: CSS:

.plus-fa {
    &:before {
        @include icon($icon-plus-fa);
        color: #0056A7;
    }
}
.minus-fa {
    &:before {
        @include icon($icon-minus-fa);
        color: #0056A7;
    }
}
.goApps {
    display:none;
    padding-bottom: 10px;
}

And the jquery function: 和jquery函数:

$(document).ready(function(){
    $(".featureToggle").click(function(){
        var togglelist = "#" + $( this ).attr('id') + '_list';
        $(togglelist).toggle();
        $( this ).toggleClass('plus-fa');
        $( this ).toggleClass('minus-fa');
    });
 });

The code used is exactly the same on the desktop version and the mobile version, although they are in difference scss files, specified for the desktop version and the mobile version. 使用的代码在桌面版本和移动版本上完全相同,尽管它们在为桌面版本和移动版本指定的不同的scss文件中。

Can anyone help me figure out why it won't work? 谁能帮我弄清楚为什么它不起作用? I am wondering if it is a "modal" limitation, or something simple I am missing. 我想知道这是“模态”限制,还是我所缺少的简单东西。

Put # inside href 将#放入href内

<p><span id="CraveTV" class="featureToggle plus-fa"></span> CraveTV </p>
<p id="CraveTV_list" class="goApps">Stream Showtime hits, HBO classics, the best sitcoms in TV history, and CraveTV originals.  Available on <a href="#">iOS</a> or <a href="#">Android</a>.</p>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM