Text goes here. I need to use this line as a...">

How to convert string to HTML element in Mithril?

Suppose I have a string <span class="msg">Text goes here</span>. I need to use this line as an HTML element on my web page. Any ideas on how to do this?

+4
source share
3 answers

Mithril provides a method m.trust. In the place where you want to receive HTML output, write m.trust( '<span class="msg">Text goes here</span>' )and you should be sorted.

+9
source

Mithril it powerl thanks to virtual dom, in the view , if you want to create the html element that you are using:

m("htmlattribute.classeCss" , "value");

So in your case:

m("span.msg" , "Text goes here");
0
source

Try to create a container in which you want to save your own span.
1. Use jQuery to select it.
2. In this selection, call the jQuery method .html()and pass the HTML to your string.
( $('.container').html(//string-goes-here)for example)

You should be able to set the internal HTML container as a string, so you want to use an HTML element.

Docs are here .

-3
source

All Articles