开发者

get innerhtml textarea

on site sample question

HTML

<textarea id="txt"></textarea>
<input type="button" value="click me" onclick="开发者_开发问答clk();" id="btn"/>

this text area is a ckeditor SCRIPT

 function clk()
   {
    alert($("#txt").html());
    alert($("#txt").val());
    alert($("#txt").text());
 //   alert($("#txt").innerhtml());

   }
   $(document).ready(function(){
               editor = CKEDITOR.replace( 'txt',{language : 'en',on :{}} );

   });

this code alert ' ' how can get innerhtml txt?? on site smaple question

Edit

when edit txt and click on btn then val() alert' '


The textarea is replaced by an iframe ( in a textarea I don't think you can put image ).

This seems to be an answer about how to get content from cke iframe : Get CKEditor content? - jQuery


Try this it will alert something if you have anything in the textarea. Since it is an input element it will have value property so just use val() method.

$("#txt").val();


you have to use getData() to get the innerhtml from CKEditor

click here


$('#txt).val(); works only for simple textarea. And you want to text CKEditor-textarea. See here stackoverflow.com/questions/4826036/get-ckeditor-content-jquery. Looks like your question is related to it.


to get inner text of textarea like .html() method you can use this code to replace \n with

$("#txt").val().replace('\n',"<br />");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜