[英]Changing page style on button click in Jekyll blog (with js or liquid templating)
我正在更新 Jekyll 博客的默认模板,并希望更改单击按钮时使用的样式。 如果我添加{%- include style_b.html -%}
,那么我可以在没有按钮的情况下使用 Liquid 模板,然后样式就会改变。
但我正在尝试添加一个按钮,在单击时从样式“a”到样式“b”来回切换。 我已经像这样添加了按钮: <button type="button" name="change_style" onclick=ChangeStyle();>change page style</button>
以便链接的按钮调用 a.js function:
function ChangeStyle() {
$("#result").load("../_includes/style_b.html");
console.log("loaded")
}
这实际上并没有改变风格,即使它是我不知道我将如何撤消它。 有没有办法在 Jekyll 中工作? 找不到任何解决方案,更不用说遵循最佳实践的解决方案了。
一旦 Jekyll 构建了站点,您就无法访问 _site 目录中的 _includes。 You'll need to make style_a.html
and style_b.html
a standalone page and not an include, or make those changes in CSS so you can target them with Javascript.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.