保存用户Markdown编辑的文章
今天突然想在自己的网站集成markdown编辑器.
markdown的官方网站:https://pandao.github.io/editor.md/examples/index.html
官方所有例子下载地址:https://codeload.github.com/pandao/editor.md/zip/master
首先我们要获得用户输入的数据,(利用官方给的方法没有成功)
根据用户输入的文本信息都会在”textarea”标签中显示 ,所以我们给标签绑定了id 名称是test-editormd2
然后我们定义了一个按钮输出用户输入信息
<input type="button" name="submit5" value="获取表单的值" onclick="btnAction()" style="padding: 5px;" />
我们给上面的按钮绑定单击事件
function btnAction(){
testEditor = editormd("test-editormd", {
width : "90%",
height : 640,
syncScrolling : "single",
path : "../lib/"
});
var byid=document.getElementById("test-editormd2").value;
alert('id值为'+byid);
}
成功如下
其中的变量byid 就是用户输入的数据