为什么我不能通过Javascript / Jquery获取tinymce textarea中的内容?有了我尝试过的所有东西,它总是给我[object HTMLTextAreaElement]
作为回应。我做错了什么?
Javascript:
function changeText2(){
var content = tinyMCE.getContent('content');
}
alert(content);
HTML:
<textarea id="content" onkeyup='changeText2()' name="page" cols="50" rows="15">
tinymce editable content in here
</textarea>
答案 0 :(得分:6)
您正在获取textarea元素。要获得其价值,请添加.value
。
答案 1 :(得分:0)
获取活动元素:
var focused = document.activeElement;
focused = WhoFocusseth(focused);
function WhoFocusseth(focused){
if(!focused || focused == document.body){
focused = null;
return focused;
} else if(document.querySelector){
focused = document.querySelector(":focus");
return focused;
}
}
现在您可以获得元素ID:
var Which_Elem_In_Focus = focused.id;
纯Javascript。