2015-07-01 54 views
1

我嘗試在JQTE文本編輯器中獲取值。我只想獲取沒有任何HTML元素或設計的值。JQTE Text value getting Style

我試過這個總線,當我在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> 

回答

0

你可以簡單地刪除HTML與格式:

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

由於現場嵌套在jqte塊,你可以上去DOM獲得的水平,使剛剛起步的文本內:

例如,如果你的領域是 「Emailsubject的」:

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

所以往上走牛逼他在DOM中找到與「.jqte」風格最接近的元素,然後我們沿着DOM找到下一個「.jqte_editor」風格。由於這將是一個jQuery對象,因此我們需要使用.eq(0)獲得第一個出現,最後只需使用.text()