JQTE文本价值也变得风格

时间:2015-07-01 20:55:36

标签: javascript jquery html5 textbox jqte

我尝试在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>

2 个答案:

答案 0 :(得分:2)

由于该字段嵌套在jqte块内,因此您可以使用DOM来达到允许获取文本的级别:

例如,如果您的字段是&#34;电子邮件主题&#34;:

$args = array(
    'numberposts' => -1,
    'post_type' => 'product',
    'product_cat' => $shopSlug,
    'product_tag' => 'contribution', //contribution in one query, merch in the other.
    'orderby' => 'date',
    'order' => 'dsc');

所以在DOM上我们找到了与样式&#34; .jqte&#34;最接近的元素,然后我们沿着DOM找到下一个样式&#34; .jqte_editor&#34;。由于这将是一个jQuery对象,我们需要首先使用.eq(0)获取,最后只需使用.text()获取文本

答案 1 :(得分:0)

您可以使用以下命令删除HTML格式:

var myContent = $('.jqte-test').val();        
var final = $(myContent).text();