[英]How can I replace the onclick action (with regex) using javascript / jQuery?
[英]How can I replace a taxonomy / category text string, onclick using javascript in a .md file?
假設 GRAV 用戶已登錄,則在單擊按鈕時刪除/更改分類法。
我試過了:
---
taxonomy:
tag:
- mountain
<code>
<script>
function removeTg() {
var ret = "mountain".replace('mountain','');
}
</script>
</code>
---
<button onclick="removeTg()">Remove tag</button>
知道如何在包裹的部分中使腳本執行和更改 .md 文件內容/字符串嗎?
---
as non visible .md taxonomy page content.
---
如果您想通過單擊 Grav 頁面文件 (.md) 的 Markdown 內容中定義的按鈕來運行腳本,以下代碼段將起作用:
---
taxonomy:
tag: mountain
---
<button onclick="removeTg()">Remove tag</button>
<script>
function removeTg() {
alert('Script is running')
}
</script>
當然,這並沒有多大作用。 如果要更改服務器上.md
文件的內容,腳本將需要向服務器提交請求。 然后自定義 Grav 插件將捕獲請求並更新/保存.md
文件。
一些注意事項:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.