[英]update html after button click
我對 html 和 js 很陌生。 現在我有一個問題:假設我有一個 html 頁面並且我在這個頁面上有兩個按鈕。 一個是在頁面上畫一個圓圈。 如果我按下這個按鈕,它會在頁面上顯示一個圓圈。 一個是用於保存這個 html 草圖。 如果我按下這個按鈕,它會保存當前的 html。 現在,我可以用相關的 js 腳本顯示圓圈,但我不知道如何保存 html。 有什么建議嗎?
如果保存意味着您要下載 HTML 文件,那么這里是一個片段:
<button on click="download()">download</button>
我們正在使用a
標簽的download
屬性。
function download() {
var a = document.createElement("a");
a.style.display = "none";
a.href = window.location.href;
a.download = "q.html"
document.body.append(a);
a.click();
}
這是一個 codepen 鏈接,可以了解代碼的作用: https ://codepen.io/AbrarShahriar/pen/WNwGXRa
請分享您的代碼,或者您可以使用svg-editor繪制形狀並輕松地將形狀保存在畫布上,
基本上在 html 5 和 js 中都支持在畫布上繪制一些形狀。
有關信息,您可以訪問 svg-editor 的官方文檔:
https://svg-edit.github.io/svgedit/releases/svg-edit-2.8.1/svg-editor.html#paste
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.