Javascript JQTE文本值也获取样式
我尝试在JQTE文本编辑器中获取该值。我只想得到没有任何HTML元素或设计的值 我尝试了这个总线,当我在UI上做一些样式设计时,它也在值中为我提供样式。但我想要的只是价值而不是风格。任何帮助对我都是好的Javascript JQTE文本值也获取样式,javascript,jquery,html,textbox,jqte,Javascript,Jquery,Html,Textbox,Jqte,我尝试在JQTE文本编辑器中获取该值。我只想得到没有任何HTML元素或设计的值 我尝试了这个总线,当我在UI上做一些样式设计时,它也在值中为我提供样式。但我想要的只是价值而不是风格。任何帮助对我都是好的 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Crea Application</title> <link href=
<!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>
Crea应用程序
切换jQTE
$(“.status”)。单击(函数()
{
//警报($(($textarea#mytextarea”).html();
jqteStatus=jqteStatus?假:真;
$('.jqte test:first').jqte({“status”:jqteStatus});
log($(“#mytextarea”).html());
jqteStatus=jqteStatus?假:真;
$('.jqte test:first').jqte({“status”:jqteStatus});
});
您只需通过以下操作删除HTML格式:
var myContent = $('.jqte-test').val();
var final = $(myContent).text();
由于该字段嵌套在jqte块中,因此可以向上移动DOM,以达到只允许获取文本的级别: 例如,如果您的字段为“emailsubject”: 因此,向上移动DOM,我们找到样式为“.jqte”的最近元素,然后向下移动DOM,找到样式为“.jqte_editor”的下一个元素。由于这将是一个jQuery对象,我们需要使用.eq(0)获取第一个实例,最后使用.text()获取文本
$("#emailsubject").closest(".jqte").find(".jqte_editor").eq(0).text();