专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > HTML/CSS

js除去字符串中的html标签,替换"为'

发布时间:2010-05-20 14:01:29 文章来源:www.iduyao.cn 采编人员:星星草
js去除字符串中的html标签,替换"为'
今天做文本域编辑和提交,文本域的内容最好带格式,于是找了一些插件,最后选择了jHtmlArea

下载地址:http://jhtmlarea.codeplex.com



<!DOCTYPE html ><html><head>    <title></title>    <script type="text/javascript" src="scripts/jquery-1.3.2.js"></script>    <script type="text/javascript" src="scripts/jquery-ui-1.7.2.custom.min.js"></script>    <link rel="Stylesheet" type="text/css" href="style/jqueryui/ui-lightness/jquery-ui-1.7.2.custom.css" />    <script type="text/javascript" src="scripts/jHtmlArea-0.8.js"></script>    <link rel="Stylesheet" type="text/css" href="style/jHtmlArea.css" />    <script type="text/javascript">            // You can do this to perform a global override of any of the "default" options        // jHtmlArea.fn.defaultOptions.css = "jHtmlArea.Editor.css";        $(function() {                        $("#txtDefaultHtmlArea").htmlarea(); // Initialize jHtmlArea's with all default values            });        });    </script><textarea id="txtDefaultHtmlArea" cols="50" rows="15"><p><h3>Test H3</h3>This is some sample text to test out the <b>WYSIWYG Control</b>.</p></textarea>    <input type="button" value="Alert HTML" onclick="alert($('#txtDefaultHtmlArea').htmlarea('html'));" />    <input type="button" value="Set HTML" onclick="$('#txtDefaultHtmlArea').htmlarea('html', 'Some <strong>HTML</strong> value.')" />    <input type="button" value="Change Color to Blue" onclick="$('#txtDefaultHtmlArea').htmlarea('forecolor', 'blue');" /></body></html>


替换字符串中的”为'
var name = '"a", "b"';name.replace(/"([^"]*)"/g, "'$1'");"'a', 'b'"


去除字符串中的html标签
var a = '<blockquote >asdfffaASDF阿德上风格</blockquote>';a.replace(/<[^>]+>/g,"");"asdfffaASDF阿德上风格"


去除所有空格:.replace(/s+/g,"")去除左边空格:.replace(/^s*/,""); 去除右边空格:.replace(/(s*$)/g,""); 去除两边空格:.replace(/^s+|s+$/g,"") 
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: