【发布时间】:2011-12-09 07:05:12
【问题描述】:
我对 contenteditable 元素的标记如下:
<iframe class="rich_text">
<html style="background:none transparent;">
<head></head>
<body contenteditable="true"></body>
</html>
</iframe>
是否有正文的选择更改事件(contenteditable)? 这样我就可以检测到选定的文本块是否有粗体/下划线等。
我尝试了一些事件处理程序(jQuery)但没有成功:
var richText = $(".rich_text"),
richTextDoc = richText.contents()[0],
richTextBody = richText.contents().find("body");
// Enable Design mode.
richTextDoc.open();
richTextDoc.write("");
richTextDoc.close();
richTextDoc.designMode = "on";
// Binds selection change event
$(richTextDoc).bind("select", function() { ... });
$(richTextDoc).bind("selectstart", function() { ... });
richTextBody .bind("select", function() { ... });
richTextBody .bind("selectstart", function() { ... });
【问题讨论】:
标签: javascript jquery