How to convert a string into a HTML element in Mithril?

前端 未结 3 649
情歌与酒
情歌与酒 2021-01-19 13:30

Suppose I have a string Text goes here.I need to use this string as a HTML element in my webpage. Any ideas on how to do

3条回答
  •  难免孤独
    2021-01-19 13:50

    Try creating a container you wish to hold your span in.
    1. Use jQuery to select it.
    2. On that selection, call the jQuery .html() method, and pass in your HTML string.
    ($('.container').html(//string-goes-here), for example)

    You should be able to assign the inner HTML of the container with the string, resulting in the HTML element you want.

    Docs here.

提交回复
热议问题