开发者

HTML Preview via JavaScript or JQuery

开发者 https://www.devze.com 2023-01-07 06:56 出处:网络
I\'d like to throw together a quick HTML preview window that takes the contents of a text area and shows it in a modal dialogue wi开发者_StackOverflow中文版th a single close button. The contents shoul

I'd like to throw together a quick HTML preview window that takes the contents of a text area and shows it in a modal dialogue wi开发者_StackOverflow中文版th a single close button. The contents should be rendered as HTML.

Not sure how to go about this.. what's the best way?


If you're using jQuery UI, something like this:

HTML

<textarea id="mytext"></textarea>
<div id="dialog"></div>

JavaScript

$('#dialog').dialog({ modal: true, autoOpen: false });

function preview() {
  $('#dialog').html($('#mytext').val());
  $('#dialog').dialog('open');
}
0

精彩评论

暂无评论...
验证码 换一张
取 消