打开和关闭手风琴小部件

发布于 2024-12-06 01:10:27 字数 617 浏览 2 评论 0原文

我正在为基本的三种媒体屏幕、平板电脑和智能手机设置不同的 CSS。我有一个两个列表,我想按原样保留在屏幕上,但希望这两个列表成为平板电脑模式下的手风琴小部件。

我的想法是继续将所有内容放入小部件中。我为平板电脑视图设置的大小将打开 jquery 脚本,而桌面视图将关闭脚本,内容将仅以正常外观显示

所以如果 SpryAccordion.js 文件如下所示:(我有一些所以我理解 if/else 语句,但不知道如何在 js 中使用它们)

(function() { // BeginSpryComponent

if (typeof Spry == "undefined") window.Spry = {};
if (!Spry.Widget) Spry.Widget = {};

Spry.Widget.Accordion = function(element, opts) {
//all the spry code...//
};

})();

我将如何包装它来打开和关闭小部件?

或者有更好的方法来做到这一点吗?我对 jquery 很陌生。我的另一个选择是在 Div 和小部件中包含重复的内容,并使用 css 打开/关闭每个可见性。

但这并不是很优雅。

请帮忙。

I am setting up different CSS for the basic three media Screen, tablet and smartphone. I have a two list I would like to leave as is for Screen but would like to have the two lists become an accordion widget in Tablet mode.

My idea was to go ahead and put everything into the widget. The size that I have set for Tablet view would turn on the jquery script and the Desktop view would turn the script off and the content would just show in normal looking 's

So if the SpryAccordion.js file looks like this: (I have some actionscript exp. So I understand if/else statements but don't know how to use them in js)

(function() { // BeginSpryComponent

if (typeof Spry == "undefined") window.Spry = {};
if (!Spry.Widget) Spry.Widget = {};

Spry.Widget.Accordion = function(element, opts) {
//all the spry code...//
};

})();

how would I wrap this to turn the widget on and off?

Or is there a better way to do this? I'm very new to jquery. My other option is to have duplicate content in a Div and the widget and turn the visibility each on/off with css.

But that just wouldn't be very elegant.

Please help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱,才寂寞 2024-12-13 01:10:27

我想我理解你的问题。所以基本上你希望能够打开和关闭手风琴,对吗?

一种方法是简单地在其自己的函数中定义 Spry.Widget.Accordion ,并且仅在您想要激活手风琴时才调用它。

这就是您所寻找的吗?

I think I understand your question. So basically you want to be able to turn the accordion on and off correct?

One way of doing it is simply define the the Spry.Widget.Accordion inside of its own function and only call it when you want to activate the accordion.

Is that kind of what you were looking for?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文