这是我找到的一个例子http://jsbin.com/awituc/25/edit
问题是如何创建一个新按钮来为所选文本添加特定颜色(可能是红色)?
解决方案:http: //jsbin.com/awituc/230/edit
向插件添加代码:
设置:
colors: [{ key: "Red", value: "#ff0000" },
{ key: "Green", value: "00ff00" },
{ key: "Blue", value: "#0000ff" }]
启动插件时可以覆盖:
$("textarea").myTextEditor({ colors: [{ key: "yellow", value: "#ffff00" }] });
落下:
var selectColor = $("<select/>", {
data: {
commandName: "ForeColor"
},
change: execCommand
}).appendTo(buttonPane);
设置颜色的代码:
$.each(settings.colors, function (i, v) {
$("<option/>", {
value: v.value,
text: v.key,
style: "color:" + v.value
}).appendTo(selectColor);
});
execCommand 参考:
http ://www.developphp.com/view_lesson.php?v=879
jQuery 插件教程:
http ://bit.ly/14dXuXL