[英]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.