1

I try to get the value in JQTE Text Editor . I want to get only values without any HTML element or design.

I tried this bus this is giving me styles also in the values when I do some styling on UI . But I want only value without style. Any help would be great for me .

<!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>
s_k_t
  • 689
  • 1
  • 15
  • 36

2 Answers2

2

Since the field is nested inside of the jqte block you can go up the DOM to get to a level that allows just getting the text:

For example if your field was "emailsubject":

$("#emailsubject").closest(".jqte").find(".jqte_editor").eq(0).text();

So going up the DOM we find the closest element with the style ".jqte", then we go down the DOM to find the next style of ".jqte_editor". Since this will be a jQuery object, we need to get the first occurance with .eq(0) and finally just get the text with .text()

0

You can simply remove the HTML formatting with:

var myContent = $('.jqte-test').val();        
var final = $(myContent).text();
Tunaki
  • 132,869
  • 46
  • 340
  • 423