首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >切换无法在Kirby中工作的JavaScript和CSS的内容

问切换无法在Kirby中工作的JavaScript和CSS的内容
EN

Stack Overflow用户
提问于 2013-03-02 08:46:05
回答 1查看 569关注 0票数 2

我正在尝试使用我在这里找到的切换代码:http://jsfiddle.net/wGbh5/。它看起来非常直截了当,完全按照我的意愿去做。

因此,我的style.css文件中有以下代码:

代码语言:javascript
复制
.clickme {
background-color: #eee;
border-radius: 4px;
color: #666;
display: block;
margin-bottom: 5px;
padding: 5px 10px;
text-decoration: none;}

.clickme:hover {
    text-decoration: underline;
}

然后,我创建了一个包含以下代码的toggle.js文件:

代码语言:javascript
复制
// Hide all the elements in the DOM that have a class of "box"
$('.box').hide();
// Make sure all the elements with a class of "clickme" are visible and bound
// with a click event to toggle the "box" state
$('.clickme').each(function() {
    $(this).show(0).on('click', function(e) {
        // This is only needed if your using an anchor to target the "box" elements
        e.preventDefault();

        // Find the next "box" element in the DOM
        $(this).next('.box').slideToggle('fast');
    });
});

我在html中使用头调用两个文件,并使用以下行

代码语言:javascript
复制
<link rel="stylesheet" href="http://localhost:8888/kirby/assets/styles/styles.css" />
<script src="http://localhost:8888/kirby/assets/js/toggle.js"></script>

正如您在链接中所看到的,我正在本地使用MAMP并试用CMS 柯比。

在HTML文件中,代码如下所示:

代码语言:javascript
复制
<a href="#" class="clickme">Click Me</a>
<div class="box">
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. 
    Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, 
    when an unknown printer took a galley of type and scrambled it to make a type
</div>

问题是,当我在浏览器中加载html文件时,它不能工作(如果它正常工作,我就会在这里)。"clickme“和"box”内容都会显示,当我单击它们时,没有任何附加内容。

有人能帮我解决我的问题吗?

提前谢谢

EN

回答 1

Stack Overflow用户

发布于 2017-10-06 10:19:53

问题在于您调用css和js文件的方式。使用kirby调用css文件的正确方法是css。

代码语言:javascript
复制
<?php echo css('assets/styles/styles.css') ?> 

对于js来说

代码语言:javascript
复制
<?php echo js('assets/js/toogle.js') ?>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15172562

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档