I am very new to web development and was wondering if there is any useful library that will allow some type of markup to be displayed created by users similar to stackoverflow. Specifically I am asking the user the post code and want them to be able to format it.

有帮助吗?

解决方案

It is actually quite simple as long as you force users to type tags as well.

If you force user to type something like this to your input form:

<b>This is bold</b> and this is not.

and use the following code:

var text = $("#input-text").val();

$("#output-element").html(text);

Then tag will be formatted as html tag and you will see bold text instead of < b > in the output element. This works for all the possible tags as well.

fiddle: http://jsfiddle.net/AKykp/

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top