- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我一直在尝试复制 FAQ Accordion 风格,就像这样 here .
问题是第一个问题是折叠的,当我点击其他问题时,它们不会打开,也不会响应我的任何点击。我应该怎么做才能使它正确?我认为我的 JQuery 有问题。
HTML 代码
<div class="accordion-header active-header">Q: Is this free?</div>
<div class="accordion-content open-content" style="display: block;">
<p>A: Yes, uploading and downloading is 100% Free for all users. We offer PRO accounts which allows for greater flexibility with uploading/downloading.</p>
</div>
<div class="accordion-header inactive-header">Q: Will my files be removed?</div>
<div class="accordion-content">
<p>A: Free/non accounts files are kept for 90 days. PRO accounts files are kept for unlimited days.</p>
</div>
<div class="accordion-header inactive-header">Q: How many files can I upload?</div>
<div class="accordion-content">
<p>A: You can upload as many files as you want, as long as each one adheres to the Terms of Service and the maximum file upload size.</p>
</div>
<div class="accordion-header inactive-header">Q: Which files types am I allowed to upload?</div>
<div class="accordion-content">
<p>A: You may upload the following types of files: Any.</p>
</div>
<div class="accordion-header inactive-header">Q: Are there any restrictions to the size of my uploaded files?</div>
<div class="accordion-content">
<p>A: Each file you upload must be less than 1.00 GB in size for free/non accounts or less than 10.00 GB in size for PRO accounts. If it is greater than that amount, your file will be rejected.</p>
</div>
<div class="accordion-header inactive-header">Q: Can I upload music or videos?</div>
<div class="accordion-content">
<p>A: Yes. Music and video hosting is permitted as long as you own the copyright on the content and it adheres to the terms and conditions.</p>
</div>
<div class="accordion-header inactive-header">Q: There are some files on our servers which may have been subject to copyright protection, how can I notify you of them?</div>
<div class="accordion-content">
<p>A: Via our <a href="report_file.html">report abuse</a> pages.</p>
</div>
<div class="accordion-header inactive-header">Q: Do files have direct links?</div>
<div class="accordion-content">
<p>A: All users are shown a download page so no direct links are available, we may introduce direct link generation in the future.</p>
</div>
CSS 代码
.accordion-header {
font-size: 18px;
background: #ebebeb;
margin: 5px 0 0 0;
padding: 14px;
border: 1px solid #D8D8D8;
cursor: pointer;
color: #8E8E8E;
text-align: left;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
}
.active-header {
-moz-border-radius: 5px 5px 0 0;
-webkit-border-radius: 5px 5px 0 0;
border-radius: 5px 5px 0 0;
background: rgb(96, 168, 227);
background-repeat: no-repeat;
background-position: right 50%;
color: white;
text-shadow: 1px 1px rgb(72, 141, 197);
}
.inactive-header {
background: url(images/inactive-header.gif) #fff;
background-repeat: no-repeat;
background-position: right 50%;
}
.inactive-header:hover {
background: url(images/inactive-header.gif) #f5f5f5;
background-repeat: no-repeat;
background-position: right 50%;
}
.accordion-content {
display: none;
padding: 18px;
width: 100%;
background: #ffffff;
border: 1px solid #cccccc;
border-top: 0;
text-align: left;
-moz-border-radius: 0 0 5px 5px;
-webkit-border-radius: 0 0 5px 5px;
border-radius: 0 0 5px 5px;
}
JS 代码
$(document).ready(function () {
'use strict';
$('.nav').onePageNav({
filter: ':not(.external)'
});
});
jQuery(document).ready(function ($) {
'use strict';
$('.animated').appear(function () {
var elem = $(this);
var animation = elem.data('animation');
if (!elem.hasClass('visible')) {
var animationDelay = elem.data('animation-delay');
if (animationDelay) {
setTimeout(function () {
elem.addClass(animation + " visible");
}, animationDelay);
} else {
elem.addClass(animation + " visible");
}
}
});
});
$(document).ready(function () {
'use strict';
$(window).scroll(function () {
if ($(this).scrollTop() > 100) {
$('.scrollup').fadeIn();
} else {
$('.scrollup').fadeOut();
}
});
$('.scrollup').click(function () {
$("html, body").animate({
scrollTop: 0
}, 600);
return false;
});
});
function showUploaderPopup() {
jQuery('#fileUploadWrapper').modal('show', {
backdrop: 'static'
}).on('shown.bs.modal');
}
function createSlowGauge() {
var opts = {
lines: 12,
angle: 0,
lineWidth: 0.25,
pointer: {
length: 0.9,
strokeWidth: 0.04,
color: '#000000'
},
limitMax: 'true',
colorStart: '#CF0808',
colorStop: '#DA0202',
strokeColor: '#E0E0E0',
generateGradient: true
};
var target = document.getElementById('canvas-slow');
var gauge = new Gauge(target).setOptions(opts);
gauge.maxValue = 100;
gauge.animationSpeed = 128;
gauge.set(9);
}
$(document).ready(function () {
$('.accordion-header').toggleClass('inactive-header');
$('.accordion-header').click(function () {
if ($(this).is('.inactive-header')) {
$('.active-header').toggleClass('active-header').toggleClass('inactive-header').next().slideToggle().toggleClass('open-content');
$(this).toggleClass('active-header').toggleClass('inactive-header');
$(this).next().slideToggle().toggleClass('open-content');
} else {
$(this).toggleClass('active-header').toggleClass('inactive-header');
$(this).next().slideToggle().toggleClass('open-content');
}
});
return false;
});
function createFastGauge() {
var opts = {
lines: 12,
angle: 0,
lineWidth: 0.25,
pointer: {
length: 0.9,
strokeWidth: 0.04,
color: '#000000'
},
limitMax: 'true',
percentColors: [
[0.0, "#000000"],
[0.50, "#cc0000"],
[1.0, "#00cc00"]
],
strokeColor: '#E0E0E0',
generateGradient: true
};
var target = document.getElementById('canvas-fast');
var gauge = new Gauge(target).setOptions(opts);
gauge.maxValue = 100;
gauge.animationSpeed = 128;
gauge.set(100);
}! function ($) {
$(function () {
var $root = $('html, body');
$('.smooth-anchor-link').click(function () {
var href = $.attr(this, 'href');
$root.animate({
scrollTop: $(href).offset().top
}, 500, function () {
window.location.hash = href;
});
return false;
});
})
}(window.jQuery);
这是 JSFiddle例如,如果您知道正确的解决方案,您可以尝试更新它:)
附言:我知道这里还有其他类似的问题,但我尝试了所有这些问题,但都没有解决我的问题。
最佳答案
你的代码抛出一个错误 Uncaught TypeError: undefined is not a function
这是由 onePageNav()
和 appear()
引起的,这些不是官方的 javascript/jQuery 函数。如果您从其他地方复制它们,它们很可能是外部插件函数。
只需从您的 javascript 中删除这两个函数即可解决您的点击问题。 JSFiddle link
请注意,您也不需要在 JSFiddle 中使用 $(document).ready(function ()
,它会自动执行此操作。
当尝试复制某些东西时,尝试自己从头开始构建它。你不会从仅仅复制整个东西中学到任何东西。尝试编写自己的函数,这样您就可以了解一切是如何工作的。 The jQuery documentations应该有帮助。
如果您有兴趣学习如何使用 Javascript 和/或 jQuery 编写代码,请尝试以下网站:
关于javascript - Accordion 样式不可展开和不可点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28325576/
我有两个可以相互交换数据的列表。我的列表之一是 Accordion 列表,您可以在其中放置数据,但也包含更多特定的 Accordion ,这些 Accordion 也允许在其中放置数据。我可以在表之间
我正在从数据库中获取记录,我必须在 Accordion 中显示这些记录。我能够显示记录。现在我正在做的是,我必须显示第一个打开的 Accordion ,然后在单击然后关闭上一个打开的 Accordio
我有一个 Accordion ,我希望具有以下功能:当用户单击链接展开时,其他展开的链接(如果有)将折叠。我知道这个功能是内置在 Accordion 插件中的,但我试图避免添加另一个库(jQuery
有点奇怪,这个。我有两个 jquery Accordion 实体,在点击一个 Accordion 中的一个项目时,我想将它动态添加到第二个 Accordion 中,并将其隐藏在原件中。 目前从 A 移
我尝试了以下代码,除了 FontAwesome 图标之外,一切都很好。我尝试在 Google 上寻找解决方案,但找不到我正在寻找的解决方案。 当我单击其中一个 Accordion 时,另一个 Acco
我正在使用 Bootstrap 制作一个响应式网站,它包含带有大量文本的嵌套 Accordion ,当您读到底部并单击下一个 Accordion 时,大量文本被折叠,我留在了页面底部。 我从 Boot
尝试创建嵌套 Accordion 时,是否可以使用 jquery 在另一个 Accordion 内部创建 anchor 链接和 Accordion ? 例如,在我的代码中我有 用于 Accordion
我正在实现一个嵌套 Accordion ,但是当我点击父级 Accordion 中的子组件时,它关闭了父级。我希望它在点击 child 时保持打开状态。 HTML: Home
我试图在 bootstrap Accordion 中添加加号和减号,当显示内容的 div 打开时显示加号,关闭时显示减号,当我打开第二个选项卡时它应该关闭其他打开的选项卡的内容(这个当前正在发生)并且
我有 Angular 5 应用程序,我正在使用 PrimeNG 组件。我创建了带有定义标题的 PrimeNG Accordion ,其中有标题和一些操作按钮,如下所示:
我有一个运行正常的Bootstrap 3.0 Accordion ,当您单击其中一个主链接时,该 Accordion 将打开。唯一的问题是,如果您单击第二个主链接,则第一个链接不会折叠-它们都保持打开
我正在尝试将 Accordion 嵌入另一个 Accordion 中,但是它不起作用,嵌入式 Accordion 只会扩展到第一个扩展 Accordion 的大小,我需要添加额外的空间才能显示内容,任
我正在尝试将 Accordion 放在 Accordion 中。但是第二个 Accordion 不能正常工作。第一个中的 Accordion 根本不起作用。任何帮助将不胜感激 :) 我的问题主要是代码
我正在尝试创建一个交互式 Accordion / Accordion /折叠动画,以便 View 在与交互时折叠/展开自身 - 以相同的方式 flipboard折叠 View ,但两侧都折叠 我认为我
您好,这是我的第一个问题,英语不是我的母语,如果我犯了一些错误,请见谅。 我在我的项目中使用 Angular 6、jQuery 和 BS。 我有两个 Accordion ,每个都有不同的类别。我们将它
我正在构建一个非常简单的 Accordion ,我想设置 ti 在页面加载时打开所有容器。让它打开单个项目(或没有项目)是没有问题的,但我怎样才能让它打开页面加载时的所有项目。 HTML
我正在处理一个刚刚添加了 Accordion 的页面。它有几个不同的 Accordion ,当单击其中任何一个时,所有 Accordion 都会打开。再次单击 Accordion 时,它应该折叠,但它
尝试弄清楚如何在 Dojo 的 Accordion dijit.layout.Accordion 容器上添加展开/折叠箭头图像,就像 dijitTitlePane / dojox.widget.Tit
我有一个 Accordion ,其中包含一些嵌套的 Accordion ,我打算将其用于移动导航。我不是最擅长 JavaScript,所以我必须找到教程才能达到现在的水平。我现在需要的只是当其他 Ac
我基本上试图关闭所有 Accordion ,只打开其中一个被单击的 Accordion 。 因此,短期内只打开一个选项卡。 这是我到目前为止所拥有的: https://jsfiddle.net/gym
我是一名优秀的程序员,十分优秀!