JQTE文本值也正在获取样式
JQTE Text value getting Style too
我试图在JQTE文本编辑器中获取该值。我只想得到没有任何HTML元素或设计的值。
我尝试了这个总线,当我在UI上做一些样式时,它也在值中给了我样式。但我只想要价值而不想要风格。任何帮助都会对我很好。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Crea Application</title>
<link href="css/jquery-te-1.4.0.css" rel="stylesheet">
<!--[if lt IE 9]>
<script src="../js/thirdparty/jquery-1.11.2.js"></script><![endif]-->
<!--[if gte IE 9]><!-->
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js" charset="utf-8"></script>
<!--<![endif]-->
<script src="js/thirdparty/jquery-te-1.4.0.min.js"></script>
<!-- <script src="js/thirdparty/jquery.cookie.js"></script>
<script src="js/thirdparty/jquery.loadmask.min.js"></script>
<script src="js/thirdparty/jquery.maskinput.js"></script>
<script src="js/thirdparty/jquery.bpopup.js"></script>
<script src="js/thirdparty/jquery-date-time.js"></script>
<script src="js/thirdparty/jquery.datetimepicker.js"></script>
<script src="js/thirdparty/jquery-timepicker.js"></script>
<script src="js/thirdparty/jquery-center.js"></script>
<script src="js/thirdparty/jquery.jqdock.js"></script>
<script src='js/thirdparty/jquery.scrollto.js'></script>
<script src='js/thirdparty/moment.js'></script>
<script src='js/thirdparty/bowsy.js'></script> -->
</head>
<body>
<textarea cols="2" rows="3" name="textarea" class="jqte-test" id="mytextarea"></textarea>
<button class="status">Toggle jQTE</button>
<script type="text/javascript">
$(".status").click(function()
{
// alert($("textarea#mytextarea").html());
jqteStatus = jqteStatus ? false : true;
$('.jqte-test:first').jqte({"status" : jqteStatus});
console.log($("#mytextarea").html());
jqteStatus = jqteStatus ? false : true;
$('.jqte-test:first').jqte({"status" : jqteStatus});
});
</script>
</body>
</html>
由于字段嵌套在jqte块中,因此您可以向上访问DOM以达到只允许获取文本的级别:
例如,如果您的字段是"emailsubject":
$("#emailsubject").closest(".jqte").find(".jqte_editor").eq(0).text();
因此,在DOM中,我们找到了样式为".jqte"的最接近的元素,然后在DOM中找到下一个样式为".jqte_editor"的元素。由于这将是一个jQuery对象,我们需要使用.eq(0)获得第一次出现,最后只需使用.text()获得文本
您可以简单地使用删除HTML格式
var myContent = $('.jqte-test').val();
var final = $(myContent).text();
相关文章:
- 使用 jQuery 获取样式属性值
- Microsoft JScript运行时错误:无法获取属性'的值;样式':对象为null或未定义
- "无法获取属性'的值;style'"当试图在IE中更改样式时
- 如何在javascript中获取样式属性的初始值
- 使用 JavaScript 获取按钮元素和样式按钮
- 获取样式的属性
- 如何从 CasperJS 获取样式表列表
- 从 javascript 获取样式设置时出现问题
- 从上一个 span 元素中获取样式
- 为什么javascript不能获取样式值,但可以更改它
- 在WordPress中,获取样式表中的网站URL
- 在javascript中设置/获取样式高度
- 如何创建一个函数来设置或获取样式属性值
- 设置CSS类后,Javascript无法获取样式
- 从head获取样式表内容
- 从ownerNode(样式标签)获取样式表对象
- JQTE文本值也正在获取样式
- 无法获取我的id's使用javascript从html中获取样式
- React Native-从函数中获取样式(Android)
- Javascript:获取样式定义不正确的元素的内容