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

今天做文本域编辑和提交,文本域的内容最好带格式,于是找了一些插件,最后选择了jHtmlArea

下载地址:[url]http://jhtmlarea.codeplex.com[/url]

[img]http://dl2.iteye.com/upload/attachment/0121/1643/d90bb9bc-a62a-334c-b779-16825ecd8a06.png[/img]


<!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 style="margin: 0 0 0 40px; border: none; padding: 0px;">asdfffaASDF阿德上风格</blockquote>';
a.replace(/<[^>]+>/g,"");

"asdfffaASDF阿德上风格"



去除所有空格:.replace(/\s+/g,"")
去除左边空格:.replace(/^\s*/,"");
去除右边空格:.replace(/(\s*$)/g,"");
去除两边空格:.replace(/^\s+|\s+$/g,"")
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值