如果用户键入:
<iframe width="420" height="315" src="http://www.youtube.com/embed/8FozVVP72Qk" frameborder="0" allowfullscreen></iframe>它会变成:
<iframe width="420" height="315" src="http://www.youtube.com/embed/8FozVVP72Qk" frameborder="0" allowfullscreen></iframe>将显示代码,而不是解释代码。
所以,只要nicedit文档是旧的并且不是很完整,我想我只是替换这些值,
我可以使用replace()函数,但是有没有一个函数可以进行这种格式转换呢?
下面是我获取值的方法:
$('body').on('submit','#new_blog',function(e){
e.preventDefault();
var textarea = $(this).find('textarea').val();
var valueWithIframeSupport = textarea.replace('<','<').replace('>','>');
/* This is what i had in mind but itdoesnt really seems an option*/
});谢谢
发布于 2012-07-09 06:46:17
尝试html()方法:
var s = '<iframe width="420" height="315" src="http://www.youtube.com/embed/8FozVVP72Qk" frameborder="0" allowfullscreen></iframe>';
$('#elem').html(s)http://jsfiddle.net/4tW2u/3/
https://stackoverflow.com/questions/11387279
复制相似问题